CLI deploy: random default names and taken-name suggestion#129
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughRefactors CLI sync flow to support explicit Create vs Upsert paths via a new SyncGateway trait, adds target resolution and name-handling (including random/default name behavior), enriches API error parsing with ApiErrorCode, and updates gateway response parsing to attach error codes. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI (run_sync)
participant State as Cached State (.statespace/state.json)
participant Gateway as Gateway (SyncGateway)
CLI->>State: read cached state
State-->>CLI: cached name / none
CLI->>CLI: resolve_target(explicit_name, cached)
CLI->>Gateway: (Create) create_application(name, files)
Gateway-->>CLI: DeployResult / name-taken error
alt name-taken
CLI->>CLI: map_create_error(name-taken -> suggestion)
else created
CLI->>State: write SyncResult (name,id,url,auth_token)
end
alt DeployMode == Upsert
CLI->>Gateway: upsert_application(files)
Gateway-->>CLI: UpsertResult
CLI->>State: write SyncResult
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@binaries/statespace-cli/src/args.rs`:
- Around line 134-136: The doc comment for the CLI option represented by the
struct field `name` is misleading; update the doc string above `pub name:
Option<String>` (the `name` arg definition) to state that the application name
is randomly generated on first run and then cached in `.statespace/state.json`
for subsequent deploys (i.e., "default: randomly generated on first run, then
reused from .statespace/state.json"), so the help text accurately reflects
steady-state behavior.
In `@binaries/statespace-cli/src/commands/sync.rs`:
- Around line 187-193: The fallback name generation currently only ensures
suggestion != name but never verifies availability; update the logic around
generate_name/suggestion to loop generating new suggestions until a proper
availability check (reuse the existing name-validation/gateway method used
elsewhere in this module—e.g., the function that checks name availability or the
same RPC used for initial validation) returns true, then use that verified
suggestion in the Error::cli message so the CLI suggests a name guaranteed to be
free.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 48156217-b37b-49ee-a82b-bd9045c1a40f
📒 Files selected for processing (2)
binaries/statespace-cli/src/args.rsbinaries/statespace-cli/src/commands/sync.rs
3035606 to
bf072ff
Compare
Summary
Summary by CodeRabbit
New Features
Improvements