Repository navigation
Conversation
The rule was decided while writing `meili search` and lived only in a comment: the CLI validates an input when it cannot hand it to the API, and otherwise sends it as it is. A body has to be parsed before the flags can be merged into it, so `--file` and `--data` are validated. A flag value is one field and can always travel as text, so the API refuses it with its own code and names the value. Two bullets in the Input section of output.md. No code: #25 implements it, and its tests pin it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
`Number` converts more than a decimal number: `0x1` and an overflow to Infinity both convert, and both change the value in silence. The bullet now says which text becomes a number, and why the line is drawn there. Follows the fix on #25, found by CodeRabbit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`--limit` and `--offset` are `Flags.integer` in `BaseCommand`, so `meili get indexes --limit abc` already answers `cli_usage` and exit 2 before any call. The second bullet said every value but a body travels as it is, which that falsifies. The line is now drawn where it really runs: a flag `--help` types, an integer or a closed list, is refused by the parser; a flag the command converts itself, a fractional number or an object, is sent as its text when the text does not spell the value. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Replaced by #27, which carries the same two bullets off This branch was cut from The correction: the first draft said every value but a body travels as it is, which |
|
Closing in favour of #27. |
What
Write down in
docs/contract/output.mdwho refuses a bad value, the CLI or the API.Contract
docs/contract/commands.md, and each route is reachable by a distinct set of flags, or the exception is recorded with its reason (or this pull request changes the contract and nothing else)The three boxes below are about a command, and this pull request adds none. Nothing in the diff touches
src/.src/lib/output.ts, errors throughsrc/lib/errors.ts$EDITOR; adeletecommand spreadsBaseCommand.confirmFlagsand its examples carry--yesfetchoutsidesrc/lib/clients/Tests
pnpm lint,pnpm typecheck,pnpm testpass locallyThe three boxes below have nothing to add here, and the promise is not untested: #25 pins both halves of it.
test/commands/search.test.tsasserts that--vector 0.1,nope --ranking-score-threshold abc --hybrid '{nope}'reaches the API as{"vector":[0.1,"nope"],"rankingScoreThreshold":"abc","hybrid":"{nope}"}, andtest/integration/meilisearch/search.test.tsasserts that a real Meilisearch answersinvalid_search_ranking_score_thresholdand exit 1.test/contract/errors.test.tsreads theErrorssection only, so thecli_input_invalidnamed in the new bullet is prose, not a second registry.--helpsnapshot added or updated on purposeSimplicity
src/lib/, is used by this command, and is named belowNothing added.
Docs
docs/contract/updated for every name, flag, variable or code this change adds or renames, or nothing to updateADR 0002 read: "the CLI returns the API response without a wrapper" and "the CLI never rewrites an API message" are the same stance one step earlier, on the way in rather than on the way out. No new ADR: this records a rule the contract already implied, it does not change a decision.
Housekeeping
No changeset:
docs/contract/is not shipped in the package. The manifest box is left unticked below because nothing insrc/commands/moved, so there was nothing to regenerate.oclif.manifest.jsonregeneratedNotes for the reviewer
The rule, in one line: the CLI validates an input only when it cannot hand it to the API.
--fileand--datakeep failing locally withcli_input_invalid, as the section already said.--help, so the CLI can answer without a round trip:cli_usage, exit 2.The last bullet also records why converting anyway is a trap, because that is the part a reader will otherwise re-discover:
Number("abc")isNaN,JSON.stringifywritesNaNasnull, and Meilisearch reads a nullrankingScoreThresholdas no threshold at all. A typo would answer exit 0 with the wrong hits. Measured on 1.54 while writing #25.One thing I did not do, say if you want it: nothing cross-references this from rule 7 of
commands.md, which is where a reader learns that an object travels as JSON text. One home per rule seemed better than two that can drift.🤖 Generated with Claude Code