cli icon indicating copy to clipboard operation
cli copied to clipboard

fix(domain): add --domain validation and fix spinner leaks in domain create

Open stantheman0128 opened this issue 7 months ago β€’ 1 comments

Summary

  • Add missing --domain flag validation in non-interactive mode β€” previously, omitting --domain would pass an empty string to the API, producing a confusing server error
  • Fix spinner goroutine leaks in 3 error paths where s.Stop() was not called before returning

Changes

Location Fix
runCreateDomainNonInteractive Add --domain empty check with clear error message
runCreateDomainNonInteractive line 192 Call s.Stop() before returning on AddDomain error
runCreateDomainInteractive line 111 Call s.Stop() before returning on CheckDomainAvailable error
runCreateDomainInteractive line 128 Call s.Stop() before returning on ListDomains error

Reproducing the bug

# Missing --domain: previously sent empty string to API
zeabur domain create --id <service-id> -g -i=false
# Before: confusing API error
# After: "Error: --domain is required in non-interactive mode"

Test plan

  • [ ] Verify domain create --id <id> -i=false without --domain returns clear error
  • [ ] Verify domain create --id <id> --domain test -g -i=false still works
  • [ ] Verify spinner does not leak on API errors (no lingering animation in terminal)

πŸ€– Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error handling in domain creation to prevent application hangs and ensure proper cleanup when errors occur
    • Added validation requiring the domain name parameter in non-interactive mode
    • Improved failure handling during domain operations to maintain system stability and prevent incomplete transactions

stantheman0128 avatar Apr 10 '26 15:04 stantheman0128

Review Change Stack

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3f7dd3b0-e462-4b41-a529-632e925686b9

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between b209bd1104b1d661908dbdc21c59175844ce77d2 and e1f3cb16324cdd39fc65d32b316afa78a6bd96a5.

πŸ“’ Files selected for processing (1)
  • internal/cmd/domain/create/create.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/cmd/domain/create/create.go

πŸ“ Walkthrough

Walkthrough

The domain creation command now stops spinners on interactive availability and listing failures, validates that non-interactive mode receives a non-blank --domain value, and stops the spinner when non-interactive domain addition fails.

Possibly related PRs

  • zeabur/cli#217: Updates the interactive domain availability failure path in the same command.
πŸš₯ Pre-merge checks | βœ… 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
βœ… Passed checks (4 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title clearly summarizes the main changes: non-interactive --domain validation and spinner cleanup in domain creation.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.

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.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot] avatar Apr 10 '26 15:04 coderabbitai[bot]

@pan93412 I addressed the requested CodeRabbit feedback in e1f3cb1 by rejecting whitespace-only domain names with strings.TrimSpace. The refreshed build-test, golangci-lint, CodeQL, and CodeRabbit checks are all green, and CodeRabbit approved the new commit. This is ready for re-review when you have a chance.

stantheman0128 avatar Jul 16 '26 03:07 stantheman0128