Skip to content

fix: add guardrail test for unescaped markdown in command descriptions#549

Merged
mwbrooks merged 2 commits into
mainfrom
mwbrooks-docs-escapes-guards
May 15, 2026
Merged

fix: add guardrail test for unescaped markdown in command descriptions#549
mwbrooks merged 2 commits into
mainfrom
mwbrooks-docs-escapes-guards

Conversation

@mwbrooks
Copy link
Copy Markdown
Member

@mwbrooks mwbrooks commented May 15, 2026

Changelog

  • N/A

Summary

This pull request adds a guardrail to prevent unescaped markdown characters from breaking the documentation website build.

After #547 revealed that unescaped { and [ in command descriptions can break the Docusaurus MDX build, this adds:

  • A unit test that walks all commands and validates their Long descriptions render correctly through the same text/template logic used by docgen
  • CLAUDE.md guidance so contributors know to escape { and [ in descriptions

Preview

  • N/A

Testing

  • Update cmd/api/api.go to remove the escaped \\{ to be { in the Long description.
  • Run make test.
  • Confirm tests fail.
--- FAIL: Test_CommandDescriptionsRenderForDocs (0.01s)
    --- FAIL: Test_CommandDescriptionsRenderForDocs/cmd.test_api (0.00s)
make: *** [test] Error 1

Notes

  • Placed in cmd/root_test.go because the test needs Init() to build the full command tree - putting it in cmd/docgen/ would create a circular import

Requirements

@mwbrooks mwbrooks self-assigned this May 15, 2026
@mwbrooks mwbrooks added docs M-T: Documentation work only code health M-T: Test improvements and anything that improves code health semver:patch Use on pull requests to describe the release version increment labels May 15, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.64%. Comparing base (d682c81) to head (7325892).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #549   +/-   ##
=======================================
  Coverage   71.64%   71.64%           
=======================================
  Files         225      225           
  Lines       19074    19074           
=======================================
  Hits        13665    13665           
  Misses       4202     4202           
  Partials     1207     1207           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mwbrooks mwbrooks added this to the Next Release milestone May 15, 2026
The docgen command parses Long descriptions as Go text/template and
renders them as MDX for the docs site. Unescaped { characters break
the Docusaurus build. This adds a test that walks all commands and
validates their descriptions render correctly, catching issues in CI
rather than at release time.
@mwbrooks mwbrooks force-pushed the mwbrooks-docs-escapes-guards branch from e5ef5b5 to 4c8e9c9 Compare May 15, 2026 17:05
@mwbrooks mwbrooks marked this pull request as ready for review May 15, 2026 17:11
@mwbrooks mwbrooks requested a review from a team as a code owner May 15, 2026 17:11
Copy link
Copy Markdown
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

@mwbrooks LGTM! This is a super neat test to include 🧪 📚 ✨

Please merge when correct but I'm now thinking of similar checks we can include for the outputs of help command?

@mwbrooks
Copy link
Copy Markdown
Member Author

@zimeg Thanks for the quick review! 🙌🏻

Feel free to follow-up for deeper checks. We could add it for Short and Example as well, but I figured the high impact is Long.

@mwbrooks mwbrooks merged commit 3720e4f into main May 15, 2026
10 checks passed
@mwbrooks mwbrooks deleted the mwbrooks-docs-escapes-guards branch May 15, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code health M-T: Test improvements and anything that improves code health docs M-T: Documentation work only semver:patch Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants