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

Improve YAML validation error messages #2191

Closed
cscheid opened this issue Aug 29, 2022 · 1 comment
Closed

Improve YAML validation error messages #2191

cscheid opened this issue Aug 29, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request yaml-validation Issues with YAML validation and autocompletion in quarto
Milestone

Comments

@cscheid
Copy link
Collaborator

cscheid commented Aug 29, 2022

image

The following error message is very hard to read:

Key sidebar has value background: primary
    logo: "images/logo.png"
...
      - href: schedule.qmd
        text: Schedule, which must be `true` or `false`

There are two problems here.

Formatting

We can improve formatting in at least three ways. If we're going to print object values that violate the schema, we should always print them by themselves instead of wrapping text around them. That error should then read like so:

Key sidebar has value 

background: primary
logo: "images/logo.png"
...
  - href: schedule.qmd
    text: Schedule

which must be `true` or `false`

I think we also shouldn't use the work key, we should use the word field.

Finally, when we're emitting error messages in contexts that have no color formatting, we should consistently use quotes (as we already do in 'true' and 'false'). The error should read

Field "sidebar" has value 

background: primary
logo: "images/logo.png"
...
  - href: schedule.qmd
    text: Schedule

which must be "true" or "false"

Better information in the case of short suggestions

This error is especially bad, though, in that it suggests that the replacement value has to be true or false.
The problem is that although these replacements work, they are not the only options. The other alternatives, though, are more complicated schemas, and our short error report doesn't show that.
Our error heuristics should try to offer short suggestions, but they should not mislead.

@cscheid cscheid added this to the v1.2 milestone Aug 29, 2022
@cscheid cscheid self-assigned this Aug 29, 2022
@cscheid cscheid added yaml-validation Issues with YAML validation and autocompletion in quarto enhancement New feature or request labels Aug 31, 2022
@cscheid
Copy link
Collaborator Author

cscheid commented Sep 14, 2022

We fixed this with the work on closed schemas.

@cscheid cscheid closed this as completed Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request yaml-validation Issues with YAML validation and autocompletion in quarto
Projects
None yet
Development

No branches or pull requests

1 participant