quarto.json.decode does not raise on invalid JSON, so pcall cannot catch it
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 84/100
Rechercherichtung
Beginne mit src/resources/pandoc/datadir/_json.lua und dem Aufruf decode_error um Zeile 212; prüfe, wie das Modul aus init.lua geladen wird, bevor common/log.lua das globale error ersetzt. Der Issue schlägt vor, beim Laden von _json.lua eine lokale Referenz auf Luas error zu speichern. Fertig ist die Änderung, wenn Fehler beim Dekodieren und Kodieren Fehler auslösen, die von pcall abgefangen werden können, während sich das Verhalten des globalen error nicht ändert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
I have:
- searched the issue tracker for similar issues
- installed the latest version of Quarto CLI
- formatted my issue following the Bug Reports guide
Bug description
quarto.json.decode does not raise an error on invalid JSON.
It prints ERROR (...) lines to the console, then returns nil.
A filter that wraps the call in pcall gets ok = true, so it cannot tell that the decode failed, and it cannot keep the lines out of the console.
The cause is in src/resources/filters/common/log.lua.
It replaces the global error with a function that only prints, which affects every Lua filter.
src/resources/pandoc/datadir/_json.lua calls that global error when it reports a decode failure (decode_error, line 212), and when encode meets a value it cannot encode.
A small fix would be for _json.lua to keep its own reference when it loads: local error = error at the top of the file.
init.lua requires _json at line 151, before main.lua imports common/log.lua, so the reference would point to Lua's own error.
quarto.json.decode and quarto.json.encode would then raise as pandoc.json does.
The global stays as it is, so the change has no effect on code that relies on the global error not stopping the render.
Quarto 2 already behaves this way: pcall(quarto.json.decode, 'not json') returns false and JSON decode error: expected ident at line 1 column 2.
Steps to reproduce
repro.lua, in the same directory as the document:
function Meta(meta)
local ok, result = pcall(quarto.json.decode, 'not json')
quarto.log.output('decode: ok=' .. tostring(ok) .. ', result=' .. tostring(result))
ok, result = pcall(error, 'boom')
quarto.log.output('error: ok=' .. tostring(ok) .. ', result=' .. tostring(result))
end
---
title: "pcall and quarto.json.decode"
format: html
filters:
- at: pre-ast
type: lua
path: repro.lua
---
Text.
Run quarto render repro.qmd.
Actual behavior
ERROR (<quarto>/share/pandoc/datadir/_json.lua:212) invalid literal 'not' at line 1 col 1
ERROR (<quarto>/share/pandoc/datadir/_json.lua:212) trailing garbage at line 1 col 5
decode: ok=true, result=nil
ERROR ([C]:-1) boom
error: ok=true, result=nil
Expected behavior
pcall(quarto.json.decode, 'not json') returns false and the error message, and nothing is printed.
The second call shows the global error itself, for context.
Your environment
- Quarto 1.11.8 (also the development build at
2bd9f23c9). - macOS on Apple silicon.
- No IDE involved: rendered from the terminal.
Quarto check output
Quarto 1.11.8
[✓] Checking environment information...
Quarto cache location: /Users/mcanouil/Library/Caches/quarto
Project: none found (single-file mode)
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.10.0: OK
Dart Sass version 1.101.0: OK
Deno version 2.9.8: OK
Typst version 0.15.1: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.11.8
Path: <quarto>/bin
[✓] Checking tools....................OK
TinyTeX: v2026.07
Chrome Headless Shell: (not installed)
VeraPDF: (not installed)
[✓] Checking LaTeX....................OK
Using: TinyTex
Path: /Users/mcanouil/Library/TinyTeX/bin/universal-darwin
Version: 2026
[✓] Checking Chrome Headless....................OK
Using: Chrome from QUARTO_CHROMIUM
Path: /Applications/Brave Browser.app/Contents/MacOS/Brave Browser
[✓] Checking basic markdown render....OK
[✓] Checking R installation...........OK
Version: 4.6.1
Path: /Library/Frameworks/R.framework/Versions/4.6/Resources
knitr: 1.51
rmarkdown: 2.31
[✓] Checking Knitr engine render......OK
[✓] Checking Python 3 installation....OK
Version: 3.9.6
Path: /Library/Developer/CommandLineTools/usr/bin/python3
Jupyter: (None)
- Vorherrschende Sprache
- JavaScript
- Sterne
- 6.1k
- Forks
- 476
- Ø Merge
- 17 Std. 16 Min.
- Gemergte PRs (30 T.)
- 112
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus quarto-dev/quarto-cli
-
accessibility bug themes
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
quarto-dev/quarto-cli#15222 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug code-annotation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
quarto-dev/quarto-cli#15215 ·
Maintainer antworten meist innerhalb von 1 Tag
-
accessibility bug website-navigation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
quarto-dev/quarto-cli#15190 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Navbar dropdown toggles have `role="link"`Evtl. vergeben @Mittalnew hat das vor 4 Tagen übernommen. Offenaccessibility bug website-navigation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
quarto-dev/quarto-cli#15188 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
accessibility bug html websites
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
quarto-dev/quarto-cli#15187 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in quarto-dev/quarto-cli
Ähnliche Issues
-
[guide] AGENTS.md claims the coverage gate, e2e and full lint run on every PR after ADR 0011 focused validationEvtl. vergeben @hivecommons-hive hat das heute übernommen. Offenagent/guide documentation hive/claimed-by-guide stage/040-covered-by-pr
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 81/100
cncf/endusers#2006 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
check:passed feeds:add
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
all-contributors/cli#587 ·
Maintainer antworten meist innerhalb von 1 Tag
-
RGAA5
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 8 Tagen
-
feedback simulation workshop
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
githubnext/gh-aw-workshop#5157 ·
Maintainer antworten meist innerhalb von 1 Tag