fix(cli): remove doubled Expected prefix from InvalidValue messages#6487
fix(cli): remove doubled Expected prefix from InvalidValue messages#6487rvaccone wants to merge 5 commits into
Conversation
🦋 Changeset detectedLatest commit: b8f34bf The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughCLI invalid-value formatting now avoids duplicated ChangesCLI invalid-value handling
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/effect/test/unstable/cli/Errors.test.ts (1)
151-190: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover missing flag values.
CliError.InvalidValue.messagehas a separate missing-value path at Line 377-379, but these tests only use non-empty values. Add avalue: ""case, including an already-prefixed expectation, to verify normalization for missing-flag errors.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/effect/test/unstable/cli/Errors.test.ts` around lines 151 - 190, Add a missing-value test in the InvalidValue suite using value: "" and a flag kind, with an expected message already prefixed by “Expected”. Assert that CliError.InvalidValue.message normalizes the prefix correctly for the missing-flag path without duplicating it, alongside the existing non-empty value cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.changeset/fix-invalid-value-doubled-expected.md:
- Around line 11-12: Add a language identifier to each fenced code block in this
changeset document, including the examples around the invalid-value message, so
the fences satisfy markdownlint MD040. Use text or another appropriate non-code
language identifier consistently.
---
Nitpick comments:
In `@packages/effect/test/unstable/cli/Errors.test.ts`:
- Around line 151-190: Add a missing-value test in the InvalidValue suite using
value: "" and a flag kind, with an expected message already prefixed by
“Expected”. Assert that CliError.InvalidValue.message normalizes the prefix
correctly for the missing-flag path without duplicating it, alongside the
existing non-empty value cases.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 88ca4934-481a-40e3-a71a-45a7117f4a17
📒 Files selected for processing (7)
.changeset/fix-invalid-value-doubled-expected.mdpackages/effect/src/unstable/cli/CliError.tspackages/effect/src/unstable/cli/Primitive.tspackages/effect/test/unstable/cli/Arguments.test.tspackages/effect/test/unstable/cli/Command.test.tspackages/effect/test/unstable/cli/Errors.test.tspackages/effect/test/unstable/cli/Primitive.test.ts
IMax153
left a comment
There was a problem hiding this comment.
Looks good, let's just trim down the verbosity in the changeset / jsdocs.
Co-authored-by: Maxwell Brown <maxwellbrown1990@gmail.com>
Co-authored-by: Maxwell Brown <maxwellbrown1990@gmail.com>
Type
Description
CliError.InvalidValue.messagerendered a doubledExpected: Expected ...prefix for values backed byPrimitive.choiceor the schema backed primitives (integer,float,boolean,date), and for choices it also repeated the offending value twice.Before:
After:
This combines both directions suggested in the issue:
Primitive.choicenow fails with a bare description of the accepted values. The offending value and theExpected:label are added byInvalidValue.message, so the value is no longer shown twice.InvalidValue.messageonly prepends itsExpected:label whenexpecteddoes not already start withExpectedorExpected:. Failure texts that are already complete sentences (schema decode messages, user supplied strings like theParam.filterdoc examples) are appended as their own sentence instead of being double labeled.The schema backed primitives keep their full schema decode sentence. Extracting a bare expected description from a schema issue would mean duplicating the
SchemaIssueformatter traversal inside the CLI package, because theAnyOfbranch of the default formatter hardcodes theExpected X, got Ysentence and is not reachable through theleafHook/checkHookextension points. The decoded actual aftergotis also genuinely informative when it differs from the raw input (got Invalid Date,got NaN).Tests: updated the
Primitive.choiceassertions, added unit coverage for bothInvalidValue.messagebranches, added a test asserting the rendered stderr line throughCommand.runWith, and corrected a stale inline snapshot inArguments.test.tsthat encoded wording which no longer exists in the codebase.Related
Closes #6312
Summary by CodeRabbit