Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report book.toml parse error when invalid fields are found #1539

Merged
merged 3 commits into from
May 24, 2021

Conversation

joshrotenberg
Copy link
Contributor

@joshrotenberg joshrotenberg commented May 19, 2021

Prior to this change, any type errors parsing the book, rust or build sections of the book.toml would be silently ignored and the default for the given section would be used instead.

This change adds an explicit check when parsing the above sections, and if an error is encountered, the error is reported rather than using the default configuration. For example, if the value of language in [book] is a list rather than a string:

[book]
language = ["en", "pt-br"]
# ...

The result will be something like:

❯ mdbook build                         
2021-05-19 10:16:43 [ERROR] (mdbook::utils): Error: Invalid configuration file
2021-05-19 10:16:43 [ERROR] (mdbook::utils):    Caused By: invalid type: sequence, expected a string for key `language`

Fixes #1522.

check config for book parse errors

add invalid_title_type

handle build and rust config errors
@joshrotenberg joshrotenberg marked this pull request as ready for review May 19, 2021 17:19
Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this will be great to fix! I don't know why the original just ignored the errors.

src/config.rs Outdated Show resolved Hide resolved
joshrotenberg and others added 2 commits May 24, 2021 11:59
Co-authored-by: Eric Huss <eric@huss.org>
Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misleading book.toml related error message
2 participants