fix(catalogue): assert x-operationId shape and correct malformed ids#10
Merged
Conversation
The catalogue parser used `splitn(5, '/')` to break an `x-operationId` into
its five expected segments (service/scope/resource/version/method). When an
id contained six or more slashes — e.g. `basic/public/profiles/update/v1/my-zip-code`
— the overflow was folded into the final segment. The version parse then
failed on the misplaced `"update"`, the operation was dropped without any
signal, and the command never appeared on the CLI surface — invisible to
Clap, tests, or snapshots because the baseline is generated by this same
parser.
Replace `splitn` with `split`, require exactly five segments, and
`debug_assert!` on both the segment-count mismatch and a non-numeric
version. Release builds still skip the bad op so one malformed entry does
not poison the whole service. Adds explicit underflow / overflow /
non-numeric-version test pairs (panic in debug, skip in release).
Also fixes three malformed x-operationIds the new assertion immediately
caught in the bundled specs:
- basic: `…/profiles/update/v1/my-zip-code` → `…/profiles/v1/update-my-zip-code`
(six segments; this previously dropped the `update-my-zip-code` command)
- social: `/statCycles/{cycleId}` GET was tagged `…/v1/export`; corrected
to `…/v1/get` to match the admin variant and the actual semantics
- lobby: `…/blocks/v1/symc` → `…/blocks/v1/sync` (typo)
Regenerated tests/fixtures/baselines and docs/reference/cli-command-catalogue.md;
operation count 1961 → 1962.
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
Hardens the catalogue parser against malformed `x-operationId` values and fixes three real-world malformed ids the new assertion immediately caught. Source: PR #34 on the internal Bitbucket mirror.
Parser hardening
The parser used `splitn(5, '/')` which silently folded any overflow into the final segment. For an id like `basic/public/profiles/update/v1/my-zip-code`, this meant `parts[3] = "update"`; the version parse then failed and the operation was dropped without any signal. The command never appeared on the CLI surface — invisible to Clap, tests, or snapshots because the baseline is generated by the same parser.
Now:
Spec fixes the assertion caught
Regenerated `tests/fixtures/baselines/{basic,lobby,social}` and `docs/reference/cli-command-catalogue.md`. Operation count: 1961 → 1962.
Test plan