chore: Move shared CLI error handling into common errors - #1483
Conversation
Extract the shared CLI error envelope, classifier, busy status, argument error, and transport error code into common/errors while keeping clicore compatibility wrappers for existing callers.
|
Warning Review limit reached
Next review available in: 2 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR relocates error-handling types and helpers from the Changesclierrors extraction and clicore aliasing
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant clicoreAliases as clicore.UnknownCommandError
participant availableCommandNames
participant ToolsCache
participant clierrors as clierrors.UnknownCommandError
Caller->>clicoreAliases: UnknownCommandError(command, cache, context)
clicoreAliases->>availableCommandNames: availableCommandNames(cache)
availableCommandNames->>ToolsCache: read Tools
availableCommandNames-->>clicoreAliases: deduplicated command names
clicoreAliases->>clierrors: UnknownCommandError(command, availableCommands, context)
clierrors-->>clicoreAliases: CLIError with AvailableCommands details
clicoreAliases-->>Caller: CLIError
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cli/common/clicore/error_aliases.go (1)
87-102: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoffDuplicate command-name dedup logic.
This dedup-and-append logic (native names +
cache.Toolsnames) mirrorsprintCommandNamesincli/dispatcher/internal/dispatcher/completion.go. Consider extracting a shared helper (e.g., in a common package) to avoid two independent implementations drifting apart.♻️ Sketch of shared helper
-func availableCommandNames(cache ToolsCache) []string { - seen := map[string]bool{} - names := []string{} - for _, name := range NativeCommandNamesForCompletion() { - seen[name] = true - names = append(names, name) - } - for _, tool := range cache.Tools { - if seen[tool.Name] { - continue - } - seen[tool.Name] = true - names = append(names, tool.Name) - } - return names -} +func availableCommandNames(cache ToolsCache) []string { + return dedupedCommandNames(NativeCommandNamesForCompletion(), cache.Tools) +}🤖 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 `@cli/common/clicore/error_aliases.go` around lines 87 - 102, The command-name dedup-and-append logic in availableCommandNames is duplicated elsewhere, so extract a shared helper for building the unique ordered command-name list and reuse it here and in printCommandNames. Keep the behavior identical for NativeCommandNamesForCompletion plus cache.Tools, and place the helper in a common package or shared internal location so both callers stay in sync.
🤖 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.
Nitpick comments:
In `@cli/common/clicore/error_aliases.go`:
- Around line 87-102: The command-name dedup-and-append logic in
availableCommandNames is duplicated elsewhere, so extract a shared helper for
building the unique ordered command-name list and reuse it here and in
printCommandNames. Keep the behavior identical for
NativeCommandNamesForCompletion plus cache.Tools, and place the helper in a
common package or shared internal location so both callers stay in sync.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: fe8070f2-e9fd-4ed0-a18c-9fa15294f7ec
📒 Files selected for processing (13)
cli/common/clicore/error_aliases.gocli/common/clicore/error_aliases_test.gocli/common/clicore/server_not_responding.gocli/common/errors/argument_error.gocli/common/errors/busy_status.gocli/common/errors/error_editor_unresponsive.gocli/common/errors/error_envelope.gocli/common/errors/error_envelope_classification.gocli/common/errors/error_envelope_test.gocli/common/errors/server_not_responding.gocli/common/errors/string_helpers.gocli/common/errors/transport_errors.gocli/common/errors/transport_errors_test.go
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Summary
User Impact
Changes
Verification