Skip to content

fix: generate error code catalog from single YAML source - #1400

Open
mysteriousskater wants to merge 1 commit into
CalloraOrg:mainfrom
mysteriousskater:security/issue-1335-consolidate-the-duplicated-error-code-references
Open

mysteriousskater wants to merge 1 commit into
CalloraOrg:mainfrom
mysteriousskater:security/issue-1335-consolidate-the-duplicated-error-code-references

Conversation

@mysteriousskater

Copy link
Copy Markdown

Overview

This PR consolidates the duplicated error code documentation into a single hand-maintained source. docs/error-codes.yaml becomes the sole source of truth; the generator now emits both src/errors/codes.ts and docs/error-code-catalog.md, the hand-written docs/error-codes.md duplicate is removed, and npm run error-codes:check verifies the generated markdown is up to date.

Related Issue

Changes

🧾 Single Source of Truth

  • [MODIFY] docs/error-codes.yaml

    • Remains the only hand-maintained error code source; no duplicate prose is kept elsewhere.
  • [DELETE] docs/error-codes.md

    • Removed the hand-written duplicate that drifted from the YAML and the generated catalog.
  • [MODIFY] scripts/generate-error-codes.mjs

    • Emits docs/error-code-catalog.md in addition to src/errors/codes.ts from the YAML source.
    • Adds a check mode so npm run error-codes:check fails when the generated markdown (or TypeScript) is stale.
  • [MODIFY] docs/error-code-catalog.md

    • Now a generated artifact reflecting the YAML source.
  • [MODIFY] package.json

    • Wires error-codes:check to the generator's check mode.
  • [MODIFY] scripts/generate-error-codes.test.mjs

    • Adds coverage for markdown output generation and staleness detection.

Verification Results

npm run error-codes:check
node --test scripts/generate-error-codes.test.mjs
Acceptance Criteria Status
Only one hand-maintained error code source remains ✅ docs/error-codes.yaml is the sole source; docs/error-codes.md removed
The markdown catalogue is generated ✅ Generator emits docs/error-code-catalog.md
error-codes:check fails when the markdown is stale ✅ Check mode compares generated output against committed files
scripts/generate-error-codes.test.mjs covers markdown output ✅ Tests assert markdown generation and staleness behavior

Security and Failure Modes

  • The check mode fails closed: any drift between the YAML source and committed generated files causes a non-zero exit, so stale docs cannot silently pass CI.
  • No validation or safeguards were weakened; the generator only adds an output target and a verification path.

Compatibility

  • src/errors/codes.ts output is unchanged in shape, so existing imports and error handling continue to work.
  • The removed docs/error-codes.md content is preserved through the generated docs/error-code-catalog.md.

Closes #1335

@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

@mysteriousskater Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Consolidate the duplicated error code references

1 participant