Skip to content

Validate the examples that follow an unvalidated language fence - #2580

Merged
SteveSandersonMS merged 1 commit into
github:mainfrom
1fanwang:1fannnw/fix-docs-validation-skip-leak
Sep 10, 2026
Merged

Validate the examples that follow an unvalidated language fence#2580
SteveSandersonMS merged 1 commit into
github:mainfrom
1fanwang:1fannnw/fix-docs-validation-skip-leak

Conversation

@1fanwang

@1fanwang 1fanwang commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Why

A maintainer who wraps an example in <!-- docs-validate: hidden --> is asking for that example to be type-checked. For three examples in this repository, it silently was not, and nothing reported a problem. The most visible one is the trusted host-bundled block in the plugin directories guide, which carries those markers for exactly that reason.

Closing a hidden block sets a pending skip so the visible copy that follows is not validated twice. A fence whose language has no validator, rust among them, was never recognized as a code block at all, so it never consumed that pending skip. The flag survived and the next validated block absorbed it instead.

Rust examples appear in nine feature guides, usually as the last language tab before the next section, so any example following one is exposed. Before this change those three blocks were extracted and discarded. After it they are checked like every other example, and a broken one would fail the build.

What changed

Fences in languages that have no validator are now tracked and consume a pending skip when they close, so the directive can no longer reach past its intended target.

Testing Done

Three previously discarded examples are now extracted and validated:

auth/authenticate.md:412
features/plugin-directories.md:248
features/session-limits.md:164

The two TypeScript ones pass locally. The C# one needs a .NET toolchain I do not have, so CI covers it.

Raw logs: extraction before and after
$ git checkout upstream/main -- scripts/docs-validation/extract.ts
$ (cd scripts/docs-validation && npm run extract) | grep -E "typescript|csharp|Total|Skipped"
  typescript     189
  csharp         56
  Total          394
  Skipped        239

$ git checkout HEAD -- scripts/docs-validation/extract.ts
$ (cd scripts/docs-validation && npm run extract) | grep -E "typescript|csharp|Total|Skipped"
  typescript     191
  csharp         57
  Total          397
  Skipped        236

$ (cd scripts/docs-validation && npm run validate:ts) | tail -6
TypeScript:
  ✅ 191 files passed

✅ All documentation code blocks are valid!

@1fanwang
1fanwang requested a review from a team as a code owner September 8, 2026 19:14
Copilot AI balanced review requested due to automatic review settings September 8, 2026 19:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused extraction fix has no unresolved review issues.

Pull request overview

Updates documentation extraction so unsupported-language fences correctly consume pending validation skips.

Changes:

  • Tracks unvalidated fenced code blocks.
  • Prevents pending skips from affecting later validated examples.
File summaries
File Description
scripts/docs-validation/extract.ts Prevents validation skips from leaking past unsupported-language fences.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@SteveSandersonMS SteveSandersonMS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually reproduced the bug this fixes: reverted extract.ts to main and re-ran the extraction/validation pipeline — the pending-skip directive leaked past unvalidated fences (e.g. rust), silently dropping examples from type-checking (confirmed against the plugin-directories.md example added in #2581, which depends on this fix). The tracked-fence fix is minimal and correctly scoped. Approving.

@SteveSandersonMS
SteveSandersonMS force-pushed the 1fannnw/fix-docs-validation-skip-leak branch from db62ae3 to 822febb Compare September 10, 2026 13:46

@SteveSandersonMS SteveSandersonMS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed the fix: reproduced the skip-leak bug by diffing extraction output on main vs. this branch (typescript 189→191, csharp 56→57, matching the PR body), and ran real validation (validate:ts: 191/191 pass, validate:cs: 57/57 pass) to confirm the newly-included examples actually type-check. Minimal, single-file fix that reuses the existing hidden-block-skip-reset pattern. Rebased onto latest main to pick up the unrelated SourceLink vulnerability fix (#2587) that was blocking the C# check.

@SteveSandersonMS
SteveSandersonMS added this pull request to the merge queue Sep 10, 2026
Closing a docs-validate hidden block sets a pending skip so the visible
copy is not validated twice. A fence whose language has no validator,
such as rust, was never recognized as a code block, so it never consumed
that skip and the next validated block absorbed it instead.

Signed-off-by: 1fanwang <1fannnw@gmail.com>
@SteveSandersonMS
SteveSandersonMS force-pushed the 1fannnw/fix-docs-validation-skip-leak branch from 822febb to be66936 Compare September 10, 2026 13:58
@SteveSandersonMS
SteveSandersonMS removed this pull request from the merge queue due to a manual request Sep 10, 2026
@SteveSandersonMS
SteveSandersonMS merged commit 44d62e0 into github:main Sep 10, 2026
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.

3 participants