Error code documentation registry#348
Open
lmars wants to merge 8 commits into
Open
Conversation
- 40165, 40166: previously curated but missing from the code → title map. - 103008 (Push transport credentials invalid): reserved for the push transport credential-rejection case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Establish errors/codes/ as the source of truth for which error codes are valid and what they mean: one Markdown file per code, with YAML frontmatter (code, title, summary) and an optional Markdown body for the detail page. Every code has a title and summary; many also carry a body. README, CLAUDE and guidelines describe the registry and how to write entries. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add errors/scripts/validate-errors.js: checks every codes/<code>.md has a matching filename/code, required code/title/summary fields, and that every errors.json code has a registry file (completeness). Wire it into the check workflow via the validate:errors npm script. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add an `identifier` frontmatter field to each codes/<code>.md: a stable, unique snake_case name that is the canonical basis for the constant each SDK generates for the code. Unlike the title (prose that may be reworded), the identifier is a frozen contract, so SDKs can generate consistent constants from the registry rather than deriving churny names from description text. Seeded from existing SDK/server constants (ably-go, then realtime-go), falling back to the title, then normalised — abbreviations expanded, UK spelling, named after the cause rather than the consequence. The validator now requires `identifier`, checks it matches ^[a-z][a-z0-9_]*$, and rejects duplicates. README, guidelines and CLAUDE document the field. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Ably documentation style guide requires US spelling. Convert the UK spellings present in the code entries (behaviour, cancelled, favour, recognised, signalled, synchronised, unauthorised, unrecognised and their inflections) to US across titles, summaries, bodies, and identifiers, and update guidelines/CLAUDE to require US spelling. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sync two codes split out in the realtime repo: - 40128 (account application limit exceeded), split from 40115. - 40151 (token connection limit exceeded), split from 80019. 40115's meaning moved to 40128, so correct 40115 in errors.json to its current "account restricted (request limit exceeded)" meaning (the registry entry already reflected this). Both new codes get an identifier. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Make errors/codes/*.md the single source of truth and derive errors.json
from it, eliminating the drift between the two (e.g. the 40115 wording that
had gone stale in errors.json). errors.json changes shape from a flat
code → title map to `{ codes: { "<code>": { identifier, title, summary } } }`,
now carrying the identifier and summary, not just a title.
- errors/scripts/generate-errors-json.js writes errors.json from the registry
(shared frontmatter parser with the validator so they can't diverge).
- json-schemas/src/errors.json describes the new shape; validate:errors-json
checks it.
- CI regenerates and `git diff --exit-code`s errors.json as a drift guard, so
it can't be hand-edited out of sync.
- The validator drops its now-redundant errors.json cross-check.
This changes the structure parsed by ably-go, ably-ruby and
ably-ai-transport-js; their generators need updating to read the new shape
and adopt `identifier` (a follow-up, per the error-docs plan).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The hand-maintained ranges table had drifted from reality and duplicated information now carried per-code in the error registry. Drop it rather than keep a second, stale source. 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
Introduces a single registry for Ably error codes under
errors/and makes it the source of truth. Each valid code is a Markdown file aterrors/codes/<code>.mdwithcode,identifier,titleandsummaryfrontmatter, plus an optional Markdown body for detail-page content.Examples:
protocol/errors.jsonis now generated from this registry, so the set of codes and their descriptions can no longer drift between the two (a drift we hit and fixed in this branch —40115).This is the ably-common groundwork for rendering error documentation in the docs site and giving SDKs a single place to source error codes and their names.
Note to reviewers
This adds a Markdown file for every error code from the existing errors.json file that have either already been reviewed in the realtime repo (e.g. see https://github.com/ably/realtime/pull/8461, https://github.com/ably/realtime/pull/8479, and https://github.com/ably/realtime/pull/8512), or that I've had Claude generate and personally reviewed.
Feel free to review those individual Markdown files, but the thing I'm really interested in is the new registry structure:
If you do leave comments on the wording of the individual errors, please leave those with an approval and I will create tickets to address those separately.
What's in here
errors/codes/*.md— the registry. One file per code (254 in total), covering everything inerrors.jsonand seeded from the curated entries authored in the realtime repo.code,identifier,titleandsummaryare required; the body is optional.identifier— a stable, uniquesnake_casename per code (e.g.token_expired), the canonical basis for the constant each SDK generates. Chosen deliberately rather than derived from the title, so it's a frozen contract that doesn't churn when copy is reworded. Seeded from existing SDK/server constants where they existed, then normalised.errors/scripts/validate-errors.js): filename ↔code, required fields,identifierformat and uniqueness, and title/summary length warnings.protocol/errors.jsonis generated from the registry (errors/scripts/generate-errors-json.js,npm run generate:errors), with a JSON schema and a drift guard — CI regenerates it and fails if the committed file is out of date, so it can't be hand-edited out of sync.errors/README.md,errors/guidelines.mdanderrors/CLAUDE.mddescribe the registry and how to add and write entries.errors.json structure change (breaking for parsers)
protocol/errors.jsonchanges from a flatcode → titlemap to a keyed object carrying the new fields:{ "codes": { "40142": { "identifier": "token_expired", "title": "Token expired", "summary": "…" } } }Consumers that only link to the file are unaffected. Consumers that parse it need updating — as follow-ups in their own repos:
identifierfor constant names.identifier.code → title.🤖 Generated with Claude Code