fix: validate JSON before parsing deployment summary output - #55
fix: validate JSON before parsing deployment summary output#55defangdevs wants to merge 1 commit into
Conversation
`defang services --json` can exit 0 but print non-JSON to stdout, which makes the summary step's jq calls fail under `set -e` and turns a successful deployment into a failed job. Validate the output with `jq empty` and fall back to `[]` the same way we already do for a non-zero exit code. Broke smoketests on both aws and gcp in defang-mvp right after this action's `main` picked up the summary feature (PR #54).
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Heads up: this is now recurring on every push to Since |
|
@defangdevs this sounds like a CLI bug |
|
Root cause landed upstream: DefangLabs/defang#2225 (merged 2026-08-19T23:39:46Z) fixes This PR's defensive "validate JSON before parsing, fall back to []" change is still good hardening independent of that fix (any future stray stdout write, from this CLI or a future one, would otherwise silently break deployment summaries again). Happy to merge as-is, or close if you'd rather rely solely on the upstream fix — your call. |
|
Another live instance of this bug: DefangLabs/defang main run https://github.com/DefangLabs/defang/actions/runs/32313014805 failed via cascading smoketest https://github.com/DefangLabs/defang-mvp/actions/runs/32315433846 (AWS BYOC). AWS deploy itself succeeded (84 resources, service healthy) but the summary step's |
Summary
defang services --jsoncan exit 0 while printing non-JSON to stdout (seen: a version-string-like line ahead of the JSON array). The summary step'sjqcalls then fail underset -e, turning an already-successful deployment into a failed job.jq emptybefore trusting it, falling back to[]on either a non-zero exit code or invalid JSON — matching the existing fallback comment's intent.This is live-breaking right now: both
Deploy Sample to aws BYOCandDeploy Sample to gcp BYOCin DefangLabs/defang-mvp's CLI Smoketests failed on the new "Deployment summary" step after this action'smainpicked up #54, even though the actual deployments succeeded and services came up healthy. That failure cascades into DefangLabs/defang's "Go package" workflow going red onmainvia the smoketest trigger.Related: DefangLabs/defang-mvp Actions run https://github.com/DefangLabs/defang-mvp/actions/runs/32288618542
Test plan
defang-github-action@mainto confirm the summary step no longer fails whendefang services --jsonoutput is unparseable