Render CLI UserError through the output formatter - #7102
Conversation
🦋 Changeset detectedLatest commit: 6439b67 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 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 |
There was a problem hiding this comment.
ℹ️ No critical issues — one minor test-name nit inline.
Reviewed changes
This PR adds user-facing rendering for CliError.UserError failures and an opt-out for host applications:
CliError.UserErrornow accepts an optionaluserMessageand falls back safely through string cause,Error.message, and a generic default.UserErroris marked with[Runtime.errorReported] = falseso the runtime logger does not duplicate CLI-rendered output (consistent withShowHelp).Command.run/runWithgained arenderErrorsoption and now render directUserErrorfailures through the installedCliOutput.Formatterbefore rethrowing the original error.- Tests cover message fallback, control-character escaping, custom-formatter integration, argument-path wrapping, and
renderErrors: falseopt-out.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta since the prior Pullfrog review (2baddb95 → 6439b674):
- Fixed
Runtime.errorReportedsemantics forUserError— the marker defaults totrueand is flipped tofalseonly after the CLI runner renders the error, so errors caught before rendering or handled withrenderErrors: falsestill reach the runtime reporter. - Extended
renderErrorsto parse error details —showHelpnow respects the flag, suppressing parse/validation error output while still printing the help document. - Prevented double-rendering in the wizard path — the re-invocation of
runWithfor wizard-generated arguments passesrenderErrors: false. - Tightened
UserError.messagefallback — emptyuserMessageand empty string causes now fall through to the next fallback. - Added tests for the new reporting semantics, wizard single-render behavior, help-only output when
renderErrors: false, and empty-message fallback. - Renamed the misleading
Errors.test.tstest flagged in the prior review to describe the "reported before render" behavior accurately.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

Summary
CliError.UserError, with safe fallbacks from its causeUserErrorfailures through the installedCliOutput.Formatterwhile preserving the failurerenderErrors: falseso host applications can own renderingValidation
nix develop -c pnpm exec vitest run packages/effect/test/unstable/cli/Errors.test.ts packages/effect/test/unstable/cli/Command.test.ts packages/effect/test/unstable/cli/Param.test.tsnix develop -c pnpm --dir packages/effect checknix develop -c pnpm lintCloses EFF-540
Closes #7089