Skip to content

fix: remove unnecessary environmentID from service delete#193

Merged
yuaanlin merged 1 commit intomainfrom
fix/delete-service-remove-env-id
Mar 23, 2026
Merged

fix: remove unnecessary environmentID from service delete#193
yuaanlin merged 1 commit intomainfrom
fix/delete-service-remove-env-id

Conversation

@yuaanlin
Copy link
Copy Markdown
Member

@yuaanlin yuaanlin commented Mar 23, 2026

Summary

  • Remove environmentID parameter from DeleteService API client method
  • Remove --env-id flag and environment resolution from the service delete command

Root Cause

The backend's deleteService GraphQL mutation only accepts _id:

// backend: service.resolvers.go
func (r *mutationResolver) DeleteService(ctx context.Context, id primitive.ObjectID) (bool, error)

But the CLI was sending an extra environmentID that doesn't exist in the schema:

// cli (before): pkg/api/service.go
DeleteService bool `graphql:"deleteService(_id: $id, environmentID: $environmentID)"`

This caused 422 Unprocessable Entity errors when deleting services.

Test plan

  • npx zeabur@latest service delete -i=false --id <service-id> -y should succeed without needing --env-id
  • go build ./... passes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor

    • Service deletion no longer requires or uses an environment ID.
  • Removed Features

    • The temporary "expose service" command and related temporary port feature have been removed.
    • Related API surface and temporary port data type used for exposing services have been removed.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 23, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f36dbcce-3ee8-4cda-9274-4a84204bd623

📥 Commits

Reviewing files that changed from the base of the PR and between eb399f8 and cc7e726.

📒 Files selected for processing (6)
  • internal/cmd/service/delete/delete.go
  • internal/cmd/service/expose/expose.go
  • internal/cmd/service/service.go
  • pkg/api/interface.go
  • pkg/api/service.go
  • pkg/model/service.go

Walkthrough

Removed the temporary service expose feature and its types; simplified service deletion by removing the environmentID parameter across the CLI, API interface, and client implementation.

Changes

Cohort / File(s) Summary
CLI — delete command
internal/cmd/service/delete/delete.go
Removed environmentID from shared Options and non-interactive wiring; interactive service resolution no longer passes environment ID; DeleteService API call updated to single serviceID argument.
CLI — expose command removed
internal/cmd/service/expose/expose.go
Entire expose subcommand (Options, NewCmdExpose, execution logic) deleted.
CLI — service command registration
internal/cmd/service/service.go
Removed import/registration of the expose subcommand.
API interface & client
pkg/api/interface.go, pkg/api/service.go
Removed ExposeService from ServiceAPI; changed DeleteService(ctx, id, environmentID)DeleteService(ctx, id) and removed environmentID from GraphQL mutation/variables. Attention: callers must be updated to new signature.
Model
pkg/model/service.go
Deleted exported TempTCPPort type (fields: ServiceID, EnvironmentID, TargetPort, NodePort, RemainSeconds).

Sequence Diagram(s)

sequenceDiagram
    rect rgba(200,200,255,0.5)
    participant CLI
    end
    rect rgba(200,255,200,0.5)
    participant ParamFiller
    end
    rect rgba(255,200,200,0.5)
    participant APIClient
    end
    rect rgba(255,255,200,0.5)
    participant Server
    end

    CLI->>ParamFiller: resolve service ID (interactive/non-interactive)
    ParamFiller-->>CLI: returns serviceID
    CLI->>APIClient: DeleteService(ctx, serviceID)
    APIClient->>Server: GraphQL mutation deleteService(_id: $id)
    Server-->>APIClient: deletion result
    APIClient-->>CLI: result / error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 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 title accurately describes the primary change: removing unnecessary environmentID from the service delete command and API.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/delete-service-remove-env-id

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/service/delete/delete.go (1)

47-56: Consider using ServiceByName instead of ServiceByNameWithEnvironment to avoid unnecessary environment selection.

The environmentID variable is populated by ServiceByNameWithEnvironment but never used after the call, since DeleteService only requires the service ID. Prompting the user for an environment they don't need to select degrades the interactive experience.

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

In `@internal/cmd/service/delete/delete.go` around lines 47 - 56, Replace the call
to f.ParamFiller.ServiceByNameWithEnvironment (which fills environmentID) with
the simpler f.ParamFiller.ServiceByName variant so the user isn't prompted for
an environment that isn't used; remove the unused environmentID variable and
call ServiceByName with the same ProjectCtx, ServiceID (&opts.id), ServiceName
(&opts.name) and CreateNew=false (use the ServiceByName options struct used by
that helper) and return any error as before.
🤖 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/service/delete/delete.go`:
- Around line 47-56: Replace the call to
f.ParamFiller.ServiceByNameWithEnvironment (which fills environmentID) with the
simpler f.ParamFiller.ServiceByName variant so the user isn't prompted for an
environment that isn't used; remove the unused environmentID variable and call
ServiceByName with the same ProjectCtx, ServiceID (&opts.id), ServiceName
(&opts.name) and CreateNew=false (use the ServiceByName options struct used by
that helper) and return any error as before.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 526a51ef-e36d-4834-a725-16c8dc477e79

📥 Commits

Reviewing files that changed from the base of the PR and between 5825374 and 6c167e1.

📒 Files selected for processing (3)
  • internal/cmd/service/delete/delete.go
  • pkg/api/interface.go
  • pkg/api/service.go

yuaanlin added a commit to zeabur/zeabur-claude-plugin that referenced this pull request Mar 23, 2026
The underlying `exposeTempTcpPort` mutation does not exist in the
backend. The CLI command has been removed in zeabur/cli#193.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@yuaanlin yuaanlin force-pushed the fix/delete-service-remove-env-id branch from 2668787 to eb399f8 Compare March 23, 2026 16:10
…pose

1. deleteService: The backend mutation only accepts `_id`, but the CLI
   was passing an extra `environmentID` causing 422 errors. Removed from
   API client, interface, and delete command.

2. service expose: The `exposeTempTcpPort` mutation does not exist in
   the backend. Removed the entire command, API method, and model.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@yuaanlin yuaanlin force-pushed the fix/delete-service-remove-env-id branch from eb399f8 to cc7e726 Compare March 23, 2026 16:13
@yuaanlin yuaanlin merged commit 4f1eb83 into main Mar 23, 2026
4 of 5 checks passed
@yuaanlin yuaanlin deleted the fix/delete-service-remove-env-id branch March 23, 2026 16:15
yuaanlin added a commit to zeabur/zeabur-claude-plugin that referenced this pull request Mar 23, 2026
- service-delete: remove `--env-id` flag (removed from CLI, backend
  `deleteService` never required environmentID)
- service-delete: add warning that `--name` requires project context
- service-expose: remove skill entirely (`exposeTempTcpPort` mutation
  does not exist in backend, command removed from CLI)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
yuaanlin added a commit to zeabur/zeabur-claude-plugin that referenced this pull request Mar 23, 2026
- service-delete: remove `--env-id` flag (removed from CLI, backend
  `deleteService` never required environmentID)
- service-delete: add warning that `--name` requires project context
- service-expose: remove skill entirely (`exposeTempTcpPort` mutation
  does not exist in backend, command removed from CLI)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
yuaanlin added a commit to zeabur/zeabur-claude-plugin that referenced this pull request Mar 23, 2026
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.

1 participant