Skip to content

fix: validate JSON before parsing deployment summary output - #55

Open
defangdevs wants to merge 1 commit into
mainfrom
fix/summary-json-validation
Open

fix: validate JSON before parsing deployment summary output#55
defangdevs wants to merge 1 commit into
mainfrom
fix/summary-json-validation

Conversation

@defangdevs

Copy link
Copy Markdown
Contributor

Summary

  • defang services --json can exit 0 while printing non-JSON to stdout (seen: a version-string-like line ahead of the JSON array). The summary step's jq calls then fail under set -e, turning an already-successful deployment into a failed job.
  • Validate the captured output with jq empty before 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 BYOC and Deploy Sample to gcp BYOC in DefangLabs/defang-mvp's CLI Smoketests failed on the new "Deployment summary" step after this action's main picked 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 on main via the smoketest trigger.

Related: DefangLabs/defang-mvp Actions run https://github.com/DefangLabs/defang-mvp/actions/runs/32288618542

Test plan

  • CI on this PR passes
  • Re-run (or wait for next) defang-mvp smoketest run against defang-github-action@main to confirm the summary step no longer fails when defang services --json output is unparseable

`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).
@defangdevs
defangdevs requested a review from a team as a code owner August 19, 2026 18:54
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 13b2ddc2-8e91-463c-98ab-f67423a8dafb


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@defangdevs

Copy link
Copy Markdown
Contributor Author

Heads up: this is now recurring on every push to defang@main, not a one-off. A second push (run https://github.com/DefangLabs/defang/actions/runs/32289380925) just hit the same failure via https://github.com/DefangLabs/defang-mvp/actions/runs/32290325677 — both aws and gcp smoketests deployed fine and failed only at the summary step with the same jq: parse error / exit code 5.

Since defang-mvp pins this action to @main (floating), every defang main push will keep going red until this merges. CI here is green — happy to have this reviewed/merged whenever convenient.

@lionello

Copy link
Copy Markdown
Member

@defangdevs this sounds like a CLI bug

@defangdevs

Copy link
Copy Markdown
Contributor Author

Root cause landed upstream: DefangLabs/defang#2225 (merged 2026-08-19T23:39:46Z) fixes term.Println/Print* writing human-readable/debug output to stdout even in --json mode — that's what was corrupting defang services --json under DEFANG_DEBUG=1 and breaking this step's jq parse.

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.

@defangdevs

Copy link
Copy Markdown
Contributor Author

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 jq crashed on non-JSON defang services --json output, exit 5 — same failure mode this PR fixes.

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.

2 participants