fix: migrate deployment telemetry to the current API - #6
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The CLI still posts to
/trpc/cli.createDeployment, which the Go API rewrite replaced withPOST /api/cli/deployments. Every call 404s, and sinceRunonly warns on telemetry failure, deployments keep exiting0while recording nothing — the failure is easy to miss in CI logs:Beyond the path, several fields had drifted from what the API accepts.
Changes
POST /trpc/cli.createDeploymentPOST /api/cli/deploymentsshop_idenvironment_idcomposerjsonbcolumn){"result":{"data":…}}Responsestructdeployment_idstringintAlso:
deployment_idnow actually prints. The oldresponse["deployment_id"].(string)assertion always failed against an integer, so the line was silently skipped.SHOPMON_BASE_URLgets a trailing slash trimmed, sohttp://host/no longer yieldshttp://host//api/....deployfails fast when no environment ID is set, instead of postingenvironment_id: 0and taking a 400 from the server.Env var naming
SHOPMON_ENVIRONMENT_IDis now the documented name.SHOPMON_SHOP_IDstays 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, andgo testall pass. The added tests round-trip the payload through a copy of the API's generatedCreateCliDeploymentRequestwithDisallowUnknownFields, which proves no renamed or leftover fields remain, thatstart_date/end_dateparse astime.Time(RFC3339), and thatcomposeris valid JSON for thejsonbcolumn.{"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