feat(errors): structured Q-15-1 diagnostic for duplicate crossref identifiers (bd-rr6qzcvu)#321
Merged
Merged
Conversation
…ntifiers (bd-rr6qzcvu, stage 1)
A duplicate crossref id (e.g. two cells both `#| label: fig-charts`) was
reported as a bare, code-less, span-less line: `Error: duplicate crossref
identifier <id>`. It rendered as plain text only because `to_text` gates the
ariadne box on `has_any_location`, and the diagnostic carried no location.
`duplicate_id_diagnostic` already *received* both occurrences' `SourceInfo`
(the first, from the index, and the duplicate) and discarded them with a TODO.
This wires them through:
- New `crossref` subsystem (number 15) + code `Q-15-1` "Duplicate Crossref
Identifier" in the catalog.
- `duplicate_id_diagnostic` rebuilt with `DiagnosticMessageBuilder`:
`.with_code("Q-15-1")`, `.with_location(second)` (underlines the duplicate),
`.add_detail_at("first defined here", first)`, a problem statement, and a
hint. Still error-level — duplicate ids are genuinely ambiguous.
- Docs page `docs/errors/crossref/Q-15-1.qmd` (new `crossref/` subsystem dir).
- Refreshed the stale `CONTRIBUTING-ERRORS.md` subsystem table (12–15).
The diagnostics already flow `ctx.diagnostics -> render_output.diagnostics`,
rendered against the document's source context, so the located form renders
with ariadne automatically — confirmed end-to-end:
Error: [Q-15-1] Duplicate crossref identifier
╭─[ dup.qmd:9:1 ]
5 │ {#fig-charts} ── first defined here
9 │ {#fig-charts} ── The crossref identifier `fig-charts` is defined more than once. …
ℹ Give one of the targets a different `label:` (or `#id`).
On the real `docs/` render the `figures.qmd` tabset duplicate now renders the
same boxed, multi-line diagnostic across both code cells.
Tests:
- Catalog presence test for Q-15-1 (subsystem `crossref`).
- Transform test `duplicate_id_diagnostic_is_coded_and_located`: code + primary
location + a located detail.
This is **stage 1** of bd-rr6qzcvu (the diagnostic). Stage 2 relabels the two
`fig-charts` cells in figures.qmd to clear the error itself — deliberately left
for a follow-up so the improved message can be seen on a real render.
Verified: `cargo nextest run --workspace` (10,289 passed) and full
`cargo xtask verify` green.
Plan: claude-notes/plans/2026-06-19-crossref-duplicate-id-diagnostic.md
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-rr6qzcvu, stage 2) The "Subcaptions" example in docs/guides/authoring/figures.qmd shows the same figure in a Jupyter tab and a Knitr tab, both labeled `#| label: fig-charts`. Because both panels live in the rendered DOM, the two cells produce a duplicate `fig-charts` id — the Q-15-1 error surfaced in stage 1. Relabel them `fig-charts-jupyter` / `fig-charts-knitr` so each is unique. No `@fig-charts` reference exists anywhere in docs/, so nothing else changes. `q2 render docs/` now reports `Rendered 169 of 169 files — 27 warnings` (was `1 error, 27 warnings`); the Q-15-1 error is gone. The remaining warnings are pre-existing Q-5-6 (missing images) and Q-13-4 (body links). Plan: claude-notes/plans/2026-06-19-crossref-duplicate-id-diagnostic.md Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
A duplicate crossref identifier (e.g. two cells both
#| label: fig-charts) was reported as a bare, code-less, span-less line:It rendered as plain text only because
to_textgates the ariadne box onhas_any_location, and the diagnostic carried no location — even thoughduplicate_id_diagnosticalready received both occurrences'SourceInfoand discarded them with a TODO.This PR (two staged commits) wires the spans through and clears the real instance.
Stage 1 — the structured diagnostic
crossrefsubsystem (number 15) + codeQ-15-1"Duplicate Crossref Identifier" in the catalog.duplicate_id_diagnosticrebuilt withDiagnosticMessageBuilder:with_code+with_location(second)(underlines the duplicate) +add_detail_at("first defined here", first)+ problem + hint. Still error-level.docs/errors/crossref/Q-15-1.qmd(newcrossref/subsystem dir).CONTRIBUTING-ERRORS.mdsubsystem table (12–15).The diagnostics already flow
ctx.diagnostics → render_output.diagnostics, rendered against the document's source context, so the located form renders with ariadne automatically:On the real
docs/render the diagnostic spans both multi-line code cells infigures.qmd.Stage 2 — clear the instance
The "Subcaptions" example in
figures.qmdshowed the same figure in a Jupyter tab and a Knitr tab, both labeledfig-charts→ a duplicate id in the rendered DOM. Relabeled tofig-charts-jupyter/fig-charts-knitr. No@fig-chartsreference exists anywhere indocs/, so nothing else changes.q2 render docs/goes from1 error, 27 warningsto27 warnings(no error).Tests
Q-15-1(subsystemcrossref).duplicate_id_diagnostic_is_coded_and_located: code + primary location + a located detail.Verification
cargo nextest run --workspace— 10,289 passed.cargo xtask verify(Rust + WASM + hub-client) — all steps passed.docs/render both show the boxed[Q-15-1]underlining both sites; after the relabel,docs/renders with 0 errors.Follows the same pattern as #318 (
Q-5-6/Q-5-7resource-copy diagnostics).Plan:
claude-notes/plans/2026-06-19-crossref-duplicate-id-diagnostic.md🤖 Generated with Claude Code