Skip to content

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

@Raymondhou0917

Description

@Raymondhou0917

Bug Description

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

Steps to Reproduce

# First deploy
npx zeabur@latest deploy --project-id <id> --name "my-app" -i=false

# Second deploy (same name)
npx zeabur@latest deploy --project-id <id> --name "my-app" -i=false
# Result: creates "my-app-over" as a new service

Root Cause

In /internal/cmd/deploy/deploy.go, when --project-id is provided without --service-id, the code calls CreateEmptyService() unconditionally without checking if a service with the same name already exists.

Suggested Fix

Before creating a new service, check if one with the same --name already exists in the project:

  1. If it exists, reuse its service ID (same as providing --service-id)
  2. Or error with: "Service 'my-app' already exists (ID: xxx). Use --service-id to redeploy, or choose a different --name."

Environment

  • CLI version: 0.14.0
  • OS: macOS (Apple Silicon)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions