Skip to content

fix: return error on domain create when domain is unavailable#217

Open
eliajhmauve wants to merge 1 commit intozeabur:mainfrom
eliajhmauve:fix/domain-create-error-handling
Open

fix: return error on domain create when domain is unavailable#217
eliajhmauve wants to merge 1 commit intozeabur:mainfrom
eliajhmauve:fix/domain-create-error-handling

Conversation

@eliajhmauve
Copy link
Copy Markdown
Contributor

@eliajhmauve eliajhmauve commented Apr 4, 2026

Summary

domain create logs a warning but returns nil (exit 0) when the domain is not available, causing CI/CD pipelines to think the domain was created successfully.

Bug

if !available {
    f.Log.Warnf("Domain %s is not available", opts.domainName)
    return nil  // exit 0 — CI/CD thinks domain was created
}

Fix

  • Return fmt.Errorf(...) instead of nil so the caller gets a non-zero exit code
  • Add missing s.Stop() before early error return to prevent spinner from continuing after failure
if !available {
    return fmt.Errorf("domain %s is not available", opts.domainName)
}

Summary by CodeRabbit

Bug Fixes

  • Enhanced error handling during domain creation to properly handle failures when domain availability checks encounter issues
  • Improved error messaging when requested domains are unavailable to provide users with explicit feedback instead of silent warnings
  • Strengthened overall reliability of the domain creation workflow through better error management and user communication

domain create logs a warning but returns nil (exit 0) when the
domain is not available, causing CI/CD pipelines to think the
domain was created successfully. Return an error instead.

Also add missing s.Stop() before early error return to prevent
the spinner from continuing after failure.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

Walkthrough

The domain creation flow now properly handles unavailable domain errors by explicitly stopping the spinner and returning an error instead of logging a warning and continuing execution, changing from non-fatal to fatal error handling.

Changes

Cohort / File(s) Summary
Domain availability error handling
internal/cmd/domain/create/create.go
Spinner now explicitly stopped before error returns; domain unavailable condition now returns error instead of logging warning and continuing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarizes the main change: fixing error handling to return an error when a domain is unavailable during domain creation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/cmd/domain/create/create.go (1)

126-130: Consider stopping spinner on error for consistency.

The same pattern fixed at line 112 exists here: if ListDomains fails, the spinner continues running. For consistency with the fix applied above, consider stopping the spinner before returning.

♻️ Suggested fix
 existedDomains, err := f.ApiClient.ListDomains(context.Background(), opts.id, opts.environmentID)
 if err != nil {
+    s.Stop()
     return err
 }

The same pattern also exists at lines 186-188 in runCreateDomainNonInteractive.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/cmd/domain/create/create.go` around lines 126 - 130, When
ListDomains fails the spinner `s` is not stopped, causing it to keep running;
update the error paths that call `f.ApiClient.ListDomains` (in the interactive
create flow and in `runCreateDomainNonInteractive`) to call `s.Stop()`
immediately before returning the error so the spinner is always stopped on
failure; locate the `s` spinner variable and add `s.Stop()` just prior to each
`return err` after `ListDomains` calls.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/cmd/domain/create/create.go`:
- Around line 126-130: When ListDomains fails the spinner `s` is not stopped,
causing it to keep running; update the error paths that call
`f.ApiClient.ListDomains` (in the interactive create flow and in
`runCreateDomainNonInteractive`) to call `s.Stop()` immediately before returning
the error so the spinner is always stopped on failure; locate the `s` spinner
variable and add `s.Stop()` just prior to each `return err` after `ListDomains`
calls.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3b4abb6e-4a51-4cc4-b50e-6a64f7d46a1b

📥 Commits

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

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

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