Skip to content

fix: reuse existing service by name instead of creating duplicates#208

Open
Raymondhou0917 wants to merge 1 commit intozeabur:mainfrom
Raymondhou0917:fix/deploy-reuse-existing-service
Open

fix: reuse existing service by name instead of creating duplicates#208
Raymondhou0917 wants to merge 1 commit intozeabur:mainfrom
Raymondhou0917:fix/deploy-reuse-existing-service

Conversation

@Raymondhou0917
Copy link
Copy Markdown

Summary

  • Before creating a new service, check if one with the same --name already exists in the project
  • If found, reuse its service ID and log: Found existing service 'my-app', redeploying...
  • Only create a new service if no match is found

Problem

When running zeabur deploy --project-id <id> --name "my-app" and a service named my-app already exists, the CLI creates a duplicate service named my-app-over instead of updating the existing one.

Changes

  • internal/cmd/deploy/deploy.go — added name-based lookup using ListAllServices before CreateEmptyService

Before/After

# Before: creates "my-app-over" as a new service
zeabur deploy --project-id <id> --name "my-app" -i=false

# After: finds and reuses existing "my-app" service
zeabur deploy --project-id <id> --name "my-app" -i=false
# Output: Found existing service 'my-app', redeploying...

Fixes #203

…eabur#203)

When deploying with `--project-id` and `--name` but without `--service-id`,
the CLI now checks if a service with the same name already exists in the
project. If found, it reuses that service instead of creating a duplicate
with a suffixed name (e.g. "my-app-over").

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 27, 2026

Warning

Rate limit exceeded

@Raymondhou0917 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 29 minutes and 39 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 29 minutes and 39 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6e553794-8b57-44c9-865c-396c47427342

📥 Commits

Reviewing files that changed from the base of the PR and between 76b8768 and 68e901c.

📒 Files selected for processing (1)
  • internal/cmd/deploy/deploy.go
✨ 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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the deploy command to prevent duplicate services by reusing an existing service when deploying to a project with the same service name, addressing the duplicate *-over service creation issue in non-interactive deploys.

Changes:

  • Look up existing services by --name within the target --project-id before creating a new service.
  • Reuse the matched service ID and log a “Found existing service … redeploying…” message.
  • Fall back to creating a new empty service only when no name match exists.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +78 to +87
existingServices, err := f.ApiClient.ListAllServices(context.Background(), projectID)
if err != nil {
return fmt.Errorf("listing services: %w", err)
}
for _, s := range existingServices {
if s.Name == opts.name {
service = s
f.Log.Infof("Found existing service '%s', redeploying...", opts.name)
break
}
Copy link
Copy Markdown
Member

@pan93412 pan93412 left a comment

Choose a reason for hiding this comment

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

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

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.

deploy without --service-id creates duplicate services instead of updating existing

3 participants