fix(render): exit non-zero on error diagnostics from successful renders#364
Merged
Merged
Conversation
…rs (bd-zcjtaz78) A render that completes (output written, no pass failure) can still carry an Error-kind diagnostic — e.g. a duplicate crossref id (Q-15-1), reported and skipped by the indexer. Such a render printed "Error: ..." and "1 error" yet exited 0, so CI reported success on output the user was told is broken. should_exit_nonzero now reads ProjectRenderSummary::diagnostic_counts, which aggregates every diagnostic source including per-document diagnostics on successful outputs: any error-severity diagnostic forces exit 1, with or without --strict. Warnings keep the existing behavior (exit 0 unless --strict). The render still completes; only the exit code changes. The gate is now generic over OutputDiagnostics so the per-output case is unit-testable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Braid strand: bd-zcjtaz78 (discovered during #362 / bd-yjs54ptg).
Problem
A render can complete successfully — output file written, no Pass-1/Pass-2 failure — while carrying a
DiagnosticKind::Errordiagnostic. Examples: a duplicate crossref identifier (Q-15-1, reported and skipped by the indexer), an include-file parse error (Q-5-3), or a Lua filter callingquarto.error(). Such a render printedError: ...and tallied1 errorin the summary line, yet exited 0 — so CI reported success on output the user was explicitly told is broken.Fix
should_exit_nonzeronow readsProjectRenderSummary::diagnostic_counts(), which aggregates every diagnostic source — pass-1/pass-2 failure diagnostics, project-level diagnostics, and per-document diagnostics on successful outputs (the previously-ignored source). Any error-severity diagnostic forces exit 1, with or without--strict. Warnings keep their existing semantics (exit 0 unless--strict);Info/Notenever gate. The render still completes and writes its output; only the exit code changes.The gate is now generic over
OutputDiagnostics, which makes the per-output case directly unit-testable. Onlycrates/quartois touched.Behavior change for non-strict users, by design: CI pipelines that currently pass despite
Error:output will start failing — the exit code now agrees with what the diagnostics already said.Testing
TDD: 3 CLI integration tests (
crates/quarto/tests/integration/render_exit_codes.rs) spawning the realq2binary against a duplicate-table-id fixture; confirmed failing first (observed1 errorwith exit 0).3 new unit tests for the gate's per-output arm (error / warning / info).
cargo nextest run --workspace: 9895 passed — no existing test relied on the old exit-0 behavior.cargo xtask verify --skip-hub-buildand clippy green.End-to-end, output inspected:
Also verified a Lua filter's
quarto.error()now yields exit 1, and a warnings-only document still exits 0.🤖 Generated with Claude Code