fix(cli): name the field and the read failure in --from request errors - #459
Conversation
|
@claude /review |
|
Claude finished @theCodeDrift's task in 2m 12s —— View job Review: fix(cli): name the field and the read failure in
|
Fixed in 5dd125f: rather than dropping the outer prefix, — AI Coding Agent |
rule create/improve and feedback send share one reader that reports the resolved path with the read error's code, the JSON parser's message, and each zod issue's field path. The CLI entry registers zod's English locale, which bundling dropped because zod declares itself side-effect free. Fixes #456
zod opens its built-in messages with "Invalid input: ", which the caller already prints as the line's lead. Strip it per issue; custom messages pass through unchanged.
5dd125f to
c2a82ea
Compare
rule create --from,rule improve --fromandfeedback send --fromread a JSON request that an agent usually writes. When that file was wrong, the error did not say which field was wrong or why the file could not be read.What changed
readJsonInput()insrc/util/json-input.tsreplaces three copies of the same read → parse → validate block.--dirinto account) and the reason, for exampleENOENT: no such file or directoryorEISDIR.;because zod's messages contain commas, and zod's ownInvalid input:lead is dropped per issue so it prints once.rule metauses the same formatter, so it names fields too.src/index.ts. zod 4.3.6 declares"sideEffects": false, so the bundler removed its ownconfig(en())call. As a result every zod issue printed by the built CLI,feedback sendincluded, read as a bareInvalid input. 4.5.4 only listscompile.jsas a side effect, so upgrading zod is not a clear fix.Output from the built CLI after this change:
Tests
test/json-input.test.tscovers ENOENT, EISDIR, invalid JSON, field paths, and an error on the whole document (labelledpayload).test/rule-from.test.tsnow runs the built CLI and assertsInvalid input: prompt: expected string, received undefined. That guards both the field path and the locale fix in the bundle.pnpm typecheckandpnpm lintare clean, and all 2,020 CLI tests pass.Fixes #456