Skip to content

CLI expects services to be deleted prior to environment deletion #4641

@iduuck

Description

@iduuck

Versions

  • Client: @electric-sql/cli, 0.0.10 (via npx @electric-sql/cli@0.0.10)
  • Electric: Electric Cloud (hosted API; no server version exposed to the CLI)

Bug description
The Per-PR environments docs show teardown as a single step after provisioning a Postgres sync service:

electric environments delete "$ENV_ID" --force

In practice, deleting an environment that still contains services fails even when --force is passed. The CLI/API returns an error along the lines of “Delete all services first.” (exit code 5 / conflict).

Reproduction:

  • Create an environment and a Postgres sync service (same flow as the docs):
ENV_ID=$(electric environments create \
  --project "$PROJECT_ID" --name "pr-123" \
  --json | jq -r '.id')
electric services create postgres \
  --environment "$ENV_ID" \
  --database-url "$DATABASE_URL" \
  --region eu-west-1 \
  --wait
  • Attempt teardown exactly as documented:
electric environments delete "$ENV_ID" --force --json
  • Observe failure: environment is not deleted; error indicates services must be removed first.
    The only reliable workaround is to list and delete every service manually before deleting the environment:
electric services list --environment "$ENV_ID" --json
electric services delete "$SERVICE_ID" --force
electric environments delete "$ENV_ID" --force

This contradicts the documented Per-PR teardown flow, which implies one environments delete --force call is sufficient. The --force flag is documented only as skipping the interactive confirmation prompt when using --json; it does not appear to cascade-delete child services, despite the Per-PR example suggesting otherwise.

Expected behavior

Either:

  • environments delete ENV_ID --force should delete the environment and all services in it (cascade teardown), matching the Per-PR docs example; or
  • The docs should explicitly require deleting services first, and the --force flag documentation should not imply that environment deletion alone is enough for teardown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions