Skip to content

feat(render): add --strict to promote warning diagnostics to errors#362

Merged
cscheid merged 2 commits into
mainfrom
feature/bd-yjs54ptg-strict-mode-warnings-as-errors
Jul 2, 2026
Merged

feat(render): add --strict to promote warning diagnostics to errors#362
cscheid merged 2 commits into
mainfrom
feature/bd-yjs54ptg-strict-mode-warnings-as-errors

Conversation

@cscheid

@cscheid cscheid commented Jul 2, 2026

Copy link
Copy Markdown
Member

Closes #220.

Summary

Adds a --strict flag to q2 render that treats warnings as errors, for CI use. Warning diagnostics are promoted to error severity (kind: Warningkind: Error) on the completed ProjectRenderSummary — the single seam every structured diagnostic flows through before anything is printed or counted — so the text output, --json-errors wire output, the error/warning counts clause, and the exit code all agree. Because promotion happens at the aggregation boundary rather than at emission sites, any warning added anywhere in the pipeline in the future (stages, transforms, Lua filters, project post-render) automatically participates in strict mode with no per-call-site opt-in.

Design notes, alternatives considered, and the architecture map are in claude-notes/plans/2026-07-02-strict-mode-warnings-as-errors.md (braid strand bd-yjs54ptg).

Semantics

  • Without --strict: behavior unchanged.
  • With --strict: everything still renders (the flag changes the outcome, not the control flow), then diagnostics print with error severity and the command exits 1 if any former warning or error is present. Info/Note are untouched.
  • Orthogonal to --fail-fast, which keeps meaning "stop at first failure" — a promoted warning does not stop the render.
  • CLI-only policy: q2 preview / hub-client stay deliberately lenient per Decision D1 (bd-creo).

Implementation

  • ProjectRenderSummary::promote_warnings_to_errors() in quarto-core covers all four diagnostic sources (pass-1/pass-2 failure diagnostics, project diagnostics, per-output diagnostics via a new OutputDiagnostics::diagnostics_mut).
  • should_exit_nonzero gains a strict arm; it defensively also fails on surviving warnings so the gate is correct independent of promotion order.
  • The externalized quarto-error-reporting crate is untouched — severity policy stays consumer-side.

Testing

  • TDD: 7 CLI integration tests (crates/quarto/tests/integration/strict_mode.rs) written first and confirmed failing, spawning the real q2 binary against an unresolved-crossref fixture; plus 7 unit tests for the promotion method and the exit gate.

  • cargo nextest run --workspace: 9884 passed. Full cargo xtask verify (incl. WASM/hub-client leg) green.

  • End-to-end, output inspected:

    $ q2 render warn.qmd --strict     # warn.qmd references @fig-nonexistent
    Error: unresolved crossref `@fig-nonexistent`: no target with this identifier was found.
    1 error
    # exit 1; warn.html still written
    
    $ q2 render warn.qmd --strict --json-errors
    {"$schema":".../json-diagnostic.json","kind":"error","title":"unresolved crossref ..."}
    

Follow-up

bd-zcjtaz78 (discovered during this work): Error-kind diagnostics on successful outputs print as error but exit 0 without --strict — the non-strict gate deliberately keeps that behavior in this PR.

🤖 Generated with Claude Code

cscheid and others added 2 commits July 2, 2026 12:26
…bd-yjs54ptg, GH #220)

Warnings are promoted to error severity at the ProjectRenderSummary
boundary — the single seam every structured diagnostic flows through
before printing/counting — so text output, --json-errors, the counts
clause, and the exit code all agree, and future warnings participate
automatically. The render itself still completes; --fail-fast keeps
its stop-at-first-failure meaning.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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 e06e8ea into main Jul 2, 2026
8 checks passed
@cscheid cscheid deleted the feature/bd-yjs54ptg-strict-mode-warnings-as-errors branch July 2, 2026 18:19
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.

feature: strict mode

2 participants