Skip to content

fix: restore CLI flag wording in shared validation errors#65

Merged
hidetzu merged 1 commit into
mainfrom
fix/cli-validation-wording
May 4, 2026
Merged

fix: restore CLI flag wording in shared validation errors#65
hidetzu merged 1 commit into
mainfrom
fix/cli-validation-wording

Conversation

@hidetzu
Copy link
Copy Markdown
Owner

@hidetzu hidetzu commented May 4, 2026

Summary

  • Introduce two sentinel errors in internal/appErrMissingPRRef (no PR URL or repo + prId) and ErrMissingRegion — and have the affected use cases (list, review, comment, create) return them instead of formatted strings.
  • Add cmd/ccpr/errors.go with a translateAppError helper that converts those sentinels to the original CLI flag-aware messages (provide a PR URL or --repo and --pr-id flags, region is required: use --region flag, ...). Each CLI command wraps the use-case call so its returned errors pass through the translator.
  • Clean up an additional inconsistency: internal/app/list.go previously returned the CLI-flavored --repo is required for list command even though the CLI pre-checks --repo itself. The use case now returns a neutral repo is required; the CLI's pre-check is unchanged so end-user wording is unaffected.
  • Tests updated: internal/app/{review,comment}_test.go use errors.Is against the new sentinels for robustness, and cmd/ccpr/errors_test.go covers the translator (matched cases, passthrough, nil).

Verification

CLI:

$ ccpr review
error: provide a PR URL or --repo and --pr-id flags

$ ccpr list --repo my-repo --config <no-region>
error: region is required: use --region flag, set region in config file, or set AWS_REGION/AWS_DEFAULT_REGION env

MCP (same condition, via JSON-RPC tools/call):

"region is required: use region option, set region in config file, or set AWS_REGION/AWS_DEFAULT_REGION env"

Type of change

  • Bug fix (fix:)
  • New feature (feat:)
  • Breaking change
  • Documentation (docs:)
  • Refactor / chore (refactor: / chore:)
  • Test (test:)

Test plan

  • make build / make build-mcp / make test / make vet / make lint all pass
  • CLI smoke confirms restored flag-aware wording for both ErrMissingPRRef and ErrMissingRegion
  • MCP smoke confirms generic wording is preserved for MCP callers

Spec-driven checklist

  • docs/use-cases.md, docs/requirements.md, docs/spec.md updated before code (or N/A for non-feature changes) — N/A; spec already describes errors abstractly without pinning string content.
  • No breaking changes to JSON output (see docs/versioning.md); only CLI/MCP error message wording changes, no JSON payload schema changes.

Related issues

Closes #63.

The list, review, comment, and create CLI paths previously surfaced
flag-aware messages such as "--repo and --pr-id flags" and
"--region flag" before their pipelines were extracted to internal/app.
After the extraction, the CLI inherited generic wording from the
shared use cases, which is appropriate for MCP callers but a small
UX regression for CLI users.

Introduce two sentinel errors in internal/app -- ErrMissingPRRef and
ErrMissingRegion -- and have the CLI translate them at the boundary
via translateAppError. The shared use cases now return surface-
neutral messages, the MCP server keeps that wording, and the CLI
restores the original flag-aware messages.
@hidetzu hidetzu merged commit e451a44 into main May 4, 2026
3 checks passed
@hidetzu hidetzu deleted the fix/cli-validation-wording branch May 4, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restore CLI flag wording in shared internal/app validation errors

1 participant