Skip to content

fix: migrate deployment telemetry to the current API - #6

Merged
shyim merged 1 commit into
mainfrom
fix/api-endpoint-migration
Aug 6, 2026
Merged

fix: migrate deployment telemetry to the current API#6
shyim merged 1 commit into
mainfrom
fix/api-endpoint-migration

Conversation

@shyim

@shyim shyim commented Aug 6, 2026

Copy link
Copy Markdown
Member

Problem

The CLI still posts to /trpc/cli.createDeployment, which the Go API rewrite replaced with POST /api/cli/deployments. Every call 404s, and since Run only warns on telemetry failure, deployments keep exiting 0 while recording nothing — the failure is easy to miss in CI logs:

Warning: Failed to send telemetry: server returned status 404: ...

Beyond the path, several fields had drifted from what the API accepts.

Changes

Was Now
Path POST /trpc/cli.createDeployment POST /api/cli/deployments
Field shop_id environment_id
composer JSON object JSON-encoded string (API takes a string, stores into a jsonb column)
Response unwrapped {"result":{"data":…}} plain JSON, via a typed Response struct
deployment_id asserted to string int

Also:

  • deployment_id now actually prints. The old response["deployment_id"].(string) assertion always failed against an integer, so the line was silently skipped.
  • SHOPMON_BASE_URL gets a trailing slash trimmed, so http://host/ no longer yields http://host//api/....
  • deploy fails fast when no environment ID is set, instead of posting environment_id: 0 and taking a 400 from the server.

Env var naming

SHOPMON_ENVIRONMENT_ID is now the documented name. SHOPMON_SHOP_ID stays accepted as a fallback: the Shopmon UI's setup snippet still emits the old name while already passing the environment ID as its value, so existing pipelines keep working. The matching UI rename is FriendsOfShopware/shopmon#781.

SHOPMON_DEPLOYMENT_NAME (#3) is preserved and now covered by a test.

Testing

go build, go vet, and go test all pass. The added tests round-trip the payload through a copy of the API's generated CreateCliDeploymentRequest with DisallowUnknownFields, which proves no renamed or leftover fields remain, that start_date/end_date parse as time.Time (RFC3339), and that composer is valid JSON for the jsonb column.

{"environment_id":42,"command":"bin/console deploy:run","return_code":0,
 "start_date":"2026-08-06T10:00:00Z","end_date":"2026-08-06T10:01:00Z",
 "execution_time":60,"composer":"{\"shopware/core\":\"6.6.0\"}","reference":"abc123"}

Verified against the API source rather than a live server — worth one real deployment against staging before tagging a release.

🤖 Generated with Claude Code

The CLI still targeted the tRPC endpoint that the Go API rewrite
replaced, so every deployment call 404'd. Because Run only warns on
telemetry failure, deployments kept exiting 0 while recording nothing.

Align the client with POST /api/cli/deployments:

- send environment_id instead of shop_id
- encode composer as a JSON string, since the API takes a string and
  stores it into a jsonb column
- decode the plain JSON response instead of unwrapping
  {"result":{"data":...}}, via a typed Response struct
- read deployment_id as an integer; the previous assertion to string
  always failed, so the ID never printed
- trim a trailing slash off SHOPMON_BASE_URL to avoid a double slash
- fail fast when no environment ID is set instead of posting
  environment_id 0 and getting a 400

SHOPMON_ENVIRONMENT_ID is the documented variable; SHOPMON_SHOP_ID stays
accepted as a legacy alias, since the Shopmon UI still emits that name
while already passing the environment ID as its value.

Tests round-trip the payload through a copy of the API's generated
request type with DisallowUnknownFields, covering the date format and
that composer is valid JSON for the jsonb column.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@shyim
shyim merged commit 3ef1cb6 into main Aug 6, 2026
1 check passed
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