Skip to content

avoid cryptic error message because of internal function not handling null value#12372

Merged
cscheid merged 4 commits intomainfrom
fix/fixup-protect-null-value
Mar 31, 2025
Merged

avoid cryptic error message because of internal function not handling null value#12372
cscheid merged 4 commits intomainfrom
fix/fixup-protect-null-value

Conversation

@cderv
Copy link
Copy Markdown
Member

@cderv cderv commented Mar 25, 2025

There could be a null value of someone does

format:
  html: null

or

format:
  html:

This is caught by YAML validation, but validation of YAML could happen after format resolution.

fixes #12369

With this PR I correctly get now for quarto preview

❯ quarto preview index.qmd
ERROR: Validation of YAML front matter failed.
ERROR: (line 3, columns 3--11) Field "revealjs" has empty value but it must instead be an object
2: format:
3:   revealjs:
            ~
4: ---

ERROR: Render failed due to invalid YAML.

Stack trace:
    at renderFileInternal (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render-files.ts:581:19)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async renderFiles (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render-files.ts:325:9)
    at async render (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render-shared.ts:104:18)
    at async renderForPreview (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/preview/preview.ts:428:24)
    at async render (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/preview/preview.ts:172:22)
    at async preview (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/preview/preview.ts:189:18)
    at async Command.actionHandler (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/preview/cmd.ts:424:7)
    at async Command.execute (https://deno.land/x/cliffy@v1.0.0-rc.3/command/command.ts:1948:7)
    at async Command.parseCommand (https://deno.land/x/cliffy@v1.0.0-rc.3/command/command.ts:1780:14)

Is this the best way to solve #12369 ? IDK but it seems an ok fix to protect against some value that fixupMergeableScalars does not handle

cderv added 2 commits March 25, 2025 15:58
… null value

There could be a null value of someone does
````
format:
  html: null
````
or
````
format:
  html:
````

This is caught by YAML validation, but validation of YAML could happen after format resolution.
@cscheid
Copy link
Copy Markdown
Member

cscheid commented Mar 31, 2025

That is a good, if very strange fix for the error! I will just add a comment pointing here, and then we can close the issue.

@cscheid cscheid marked this pull request as ready for review March 31, 2025 18:58
@cderv
Copy link
Copy Markdown
Member Author

cderv commented Mar 31, 2025

Great. I wanted to discuss this and forgot last week.

Very strange fix indeed but definitely solves the problem.

We can still discuss this validation order even after merge.

Thanks for having look into it !

@cscheid cscheid merged commit 799e907 into main Mar 31, 2025
49 checks passed
@cscheid cscheid deleted the fix/fixup-protect-null-value branch March 31, 2025 20:00
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.

Missing/null YAML value leads to bad error message

2 participants