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

Bad error message on invalid YAML #2349

Closed
3 of 4 tasks
schochastics opened this issue Sep 8, 2022 · 6 comments · Fixed by #2367
Closed
3 of 4 tasks

Bad error message on invalid YAML #2349

schochastics opened this issue Sep 8, 2022 · 6 comments · Fixed by #2367
Assignees
Labels
bug Something isn't working yaml-validation Issues with YAML validation and autocompletion in quarto

Comments

@schochastics
Copy link

schochastics commented Sep 8, 2022

Bug description

On my quarto page, I have utterance activated on 2 docs. On these two pages I have the following in my yaml header which has worked at least until quarto 1.1.128

comments:
  utterances:
    repo: schochastics/quarto-schochastics
    issue-term: pathname
    label: comment
    theme: photon-dark
    crossorigin: anonymous

Starting with quarto 1.1.178 I get this error when rendering

ERROR: Validation of YAML front matter failed.
ERROR: In file material/netVizR/index.qmd
(line 13, column 3 through line 18, column 26) Key comments has value utterances:
    repo: schochastics/quarto-schochastics
...
    theme: photon-dark
    crossorigin: anonymous, which must be 'false'
12: comments:
13:   utterances:
      ~~~~~~~~~~~
14:     repo: schochastics/quarto-schochastics
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
17:     theme: photon-dark
    ~~~~~~~~~~~~~~~~~~~~~~
18:     crossorigin: anonymous
    ~~~~~~~~~~~~~~~~~~~~~~~~~
19: ---

ERROR: Render failed due to invalid YAML.

I did not change any code just wanted to re-render after installing the new quarto version
I am running Ubuntu 20.04

Checklist

  • Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
  • Please format your issue so it is easier for us to read the bug report.
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.
@schochastics schochastics added the bug Something isn't working label Sep 8, 2022
@cderv
Copy link
Collaborator

cderv commented Sep 8, 2022

I think we did some change to be more strict on YAML schema and validation.

I don't think you need to provide crossorigin: anonymous. It is not among the known options (https://quarto.org/docs/reference/projects/websites.html#utterances) and I think it will be added as anonymous by default.

So I would just remove that field. Does that work ?

@schochastics
Copy link
Author

yep that does the trick, thanks!

@cderv
Copy link
Collaborator

cderv commented Sep 8, 2022

@cscheid Just wondering if we could / should try to improve the error message for a field that is not in the schema ?

utterances:
object:
closed: true
properties:
repo:
string:
description: The Github repo that will be used to store comments.
label:
string:
description: The label that will be assigned to issues created by Utterances.
theme:
string:
description:
short: The Github theme that should be used for Utterances.
long: |
The Github theme that should be used for Utterances
(`github-light`, `github-dark`, `github-dark-orange`,
`icy-dark`, `dark-blue`, `photon-dark`, `body-light`,
or `gruvbox-dark`)
completions:
- github-light
- github-dark
- github-dark-orange
- icy-dark
- dark-blue
- photon-dark
- body-light
- gruvbox-dark
issue-term:
string:
description:
short: How posts should be mapped to Github issues
long: |
How posts should be mapped to Github issues
(`pathname`, `url`, `title` or `og:title`)
completions:
- pathname
- url
- title
- og:title
required: [repo]

Current error seems to be

crossorigin: anonymous, which must be 'false'

image

Not sure so hence I am asking before reopening or not. thanks !

@cscheid
Copy link
Collaborator

cscheid commented Sep 8, 2022

Yes, that error is atrocious. Thanks for flagging. Let me see if I can figure out why it's coming up like that.

@cscheid cscheid reopened this Sep 8, 2022
@cscheid cscheid self-assigned this Sep 8, 2022
@cscheid cscheid added the yaml-validation Issues with YAML validation and autocompletion in quarto label Sep 8, 2022
@cscheid cscheid changed the title invalid YAML when using utterances Bad error message on invalid YAML Sep 8, 2022
@cscheid
Copy link
Collaborator

cscheid commented Sep 8, 2022

Previous error message:

ERROR: Validation of YAML front matter failed.
ERROR: In file issue-2349.qmd
(line 3, column 3 through line 8, column 26) Field "comments" has value

utterances:
  repo: schochastics/quarto-schochastics
...
  theme: photon-dark
  crossorigin: anonymous

The value must instead be 'false'.
2: comments:
3:   utterances:
     ~~~~~~~~~~~
4:     repo: schochastics/quarto-schochastics
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
7:     theme: photon-dark
   ~~~~~~~~~~~~~~~~~~~~~~
8:     crossorigin: anonymous
   ~~~~~~~~~~~~~~~~~~~~~~~~~
9: ---

ERROR: Render failed due to invalid YAML.

Yuck.

New error message:

ERROR: Validation of YAML front matter failed.
ERROR: In file issue-2349.qmd
(line 8, columns 5--16) property name crossorigin is invalid
7:     theme: photon-dark
8:     crossorigin: anonymous
       ~~~~~~~~~~~
9: ---
ℹ The error happened in location comments:utterances:crossorigin.

Yay! Pull request incoming.

@cderv
Copy link
Collaborator

cderv commented Sep 8, 2022

🤯 so good ! Really cool improvement! 👏

cscheid added a commit that referenced this issue Sep 8, 2022
this changes the schemas and validator to explicitly track `closed: true`, so that our error reporting is more accurate.

Closes #2349
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working yaml-validation Issues with YAML validation and autocompletion in quarto
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants