Skip to content

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

Merged
pan93412 merged 2 commits into
zeabur:mainfrom
stantheman0128:fix/domain-create-non-interactive-validation
Jul 16, 2026
Merged

fix(domain): add --domain validation and fix spinner leaks in domain create#222
pan93412 merged 2 commits into
zeabur:mainfrom
stantheman0128:fix/domain-create-non-interactive-validation

Conversation

@stantheman0128

@stantheman0128 stantheman0128 commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

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
    • Prevented command hangs by ensuring progress indicators are properly stopped on error paths during domain creation.
    • Added validation for domain name in non-interactive mode, rejecting empty or whitespace-only values.
    • Improved error handling consistency so failures during domain operations fail cleanly without leaving incomplete state.

…create

In non-interactive mode, `domain create` proceeds with an empty domain
name if --domain is not provided, causing a confusing API error. Add
validation to require the --domain flag.

Also fix spinner goroutine leaks where s.Stop() is not called before
returning on error in both interactive and non-interactive paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 10, 2026

Copy link
Copy Markdown

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 b209bd1 and e1f3cb1.

📒 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 coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/cmd/domain/create/create.go`:
- Around line 167-169: The current non-interactive validation only checks
opts.domainName == "" and allows whitespace-only names; change the check to trim
whitespace (e.g., use strings.TrimSpace on opts.domainName) and treat a trimmed
empty string the same as missing, returning the existing error
fmt.Errorf("--domain is required in non-interactive mode"); update the
validation in the same function where opts.domainName is currently checked so
whitespace-only inputs are rejected early.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a1eeadaf-a745-4546-b8e1-d7173cb19c6a

📥 Commits

Reviewing files that changed from the base of the PR and between 4750f37 and b209bd1.

📒 Files selected for processing (1)
  • internal/cmd/domain/create/create.go

Comment thread internal/cmd/domain/create/create.go Outdated

@pan93412 pan93412 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to resolve CodeRabbit's suggestion (or explain why their suggestion is invalid)

@stantheman0128

Copy link
Copy Markdown
Contributor Author

@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.

@pan93412
pan93412 merged commit ace3c33 into zeabur:main Jul 16, 2026
5 checks passed
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.

2 participants