Skip to content

feat(jupyter,quarto-core): cell-options facility + error policy (bd-ohvl879u)#363

Merged
cscheid merged 1 commit into
mainfrom
bugfix/bd-ohvl879u-jupyter-engine-ignores-error
Jul 2, 2026
Merged

feat(jupyter,quarto-core): cell-options facility + error policy (bd-ohvl879u)#363
cscheid merged 1 commit into
mainfrom
bugfix/bd-ohvl879u-jupyter-engine-ignores-error

Conversation

@cscheid

@cscheid cscheid commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #360 (bd-gthycd33). Fixes bd-ohvl879u: q2's jupyter engine unconditionally embedded a failing cell's error as .cell-output-error output and reported success, while knitr fails the whole render (Q1's default execute: error: false policy). The fix rides on a new shared cell-options facility — the design center of this PR.

The facility: quarto-core/src/cell_options/

q2's single implementation of identifying and extracting the #|-style YAML options block at the head of an executable code cell (Q1 grew four divergent copies; q2 had two partial ad-hoc ones — the crossref shorthand's string matcher and the LSP's highlight-only directive_tokens):

  • Language-aware registry ported from Q1's kLangCommentChars: #| for python/R, --| for lua/sql, //| for js/rust, %| matlab, block-comment forms (/*| … */ for C, (*| … *) OCaml, *| … ; SAS); unknown → #.
  • Partition mirrors Q1's partition-cell-options.ts: leading-run only, column-0 anchored, prefix + ws + | + one optional space, suffix required+elided for block-comment languages.
  • Exact source attribution: the reassembled YAML's provenance is SourceInfo::concat of per-line substrings; for prefix-only languages the ranges run through each line's newline, so every byte of the reassembled YAML is a real source bytemap_offset on any parsed node resolves exactly. Parsed with quarto_yaml::parse_with_parent.
  • Scoped resolution (new vs Q1): cell options convert to ConfigValue (pampa::yaml_to_config_value) and merge over the document's already-merged execute metadata (MergedConfig, cell wins) — the start of scoped document-metadata resolution in cell options, a longstanding Q1 limitation.

The engine consumer

text_execute.rs now partitions each cell and:

  • strips option lines from kernel input and echoed .cell-code (Q1/knitr parity — verified empirically that knitr strips them; cell magics would otherwise break);
  • resolves error: via the scoped merge: per-cell #| error: true ⇒ embed error output; document execute: error: true ⇒ default-allow; cell error: false overrides a document allow; absent everywhere ⇒ the render fails (knitr/Q1 parity), halting before later cells run;
  • malformed option YAML is a hard, located error.

Diagnostics resolve to original-file coordinates through ExecutionContext.source_info (no new plumbing needed), e.g.:

Error: Execution failed in jupyter: code cell at …/fail.qmd:9:2 raised Exception: boom-e2e
Use `#| error: true` on the cell (or `execute: error: true` in the document metadata) to show the error in the output instead.

Tests

  • 28 facility unit tests (registry / partition / source-mapping / scoped-resolution matrix), TDD reds confirmed before implementation.
  • engine_error_policy.rs: 7 kernel-gated integration tests covering the full policy matrix.
  • engine_output_parity.rs gains a behavioral parity case (both engines must fail identically on un-annotated errors); all bd-gthycd33 fences unchanged and green.
  • Workspace suite 9924/9924 on the rebased tree; full cargo xtask verify passed; clippy/lint/fmt clean.
  • E2E through the real binary: all three policy paths inspected (q2 render), plus a q2 preview browser spot-check (directive-bearing healthy cell: stripped echo, spliced output) after the full WASM chain rebuild.

Follow-ups filed (discovered-from bd-ohvl879u): bd-eizgnxlx (migrate crossref shorthand to the facility), bd-1gty7f7o (LSP reuse), bd-2xkpy5ra (body-only CodeBlock SourceInfo), bd-moef1ec4 (eval option), bd-2lc8qu6e (guessChunkOptionsFormat).

Plan with full evidence: claude-notes/plans/2026-07-02-bd-ohvl879u-cell-options-error-policy.md.

🤖 Generated with Claude Code

…ailing cell aborts the render unless error: true (bd-ohvl879u)

Add quarto-core/src/cell_options: language-aware `#|` option-block
partitioning (Q1 kLangCommentChars registry) with exact source
attribution (SourceInfo::concat of per-line substrings into
quarto-yaml), plus scoped resolution: cell options merge over the
document's execute metadata via ConfigValue (cell wins).

The jupyter engine now consumes it: option lines are stripped from
kernel input and echo (Q1/knitr parity), and a raising cell fails the
render with an original-file-located diagnostic unless the cell
(#| error: true) or the document (execute: error: true) allows it —
closing the error-policy divergence with knitr.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@posit-snyk-bot

posit-snyk-bot commented Jul 2, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cscheid cscheid merged commit 87fef77 into main Jul 2, 2026
8 checks passed
@cscheid cscheid deleted the bugfix/bd-ohvl879u-jupyter-engine-ignores-error branch July 2, 2026 18:50
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.

2 participants