From bed31569c808c76e4fd2992aa16fdca3896d3718 Mon Sep 17 00:00:00 2001 From: defangdevs Date: Wed, 19 Aug 2026 11:54:24 -0700 Subject: [PATCH] fix: validate JSON before parsing deployment summary output `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). --- action.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/action.yaml b/action.yaml index 0232c5b..4986854 100644 --- a/action.yaml +++ b/action.yaml @@ -254,9 +254,11 @@ runs: # Fetch the deployed services as JSON. Compose files, stack, provider, # and project come from the environment set earlier, so they don't # need to be passed again. - # Only fall back to an empty array on failure, so a successful run - # never yields two concatenated JSON values. - if services=$(defang services --json 2>/dev/null); then + # Fall back to an empty array whenever the command fails OR its + # output isn't valid JSON (e.g. a stray CLI banner/warning line) — + # this step is best-effort reporting and must never fail the job + # over a deployment that already succeeded. + if services=$(defang services --json 2>/dev/null) && echo "$services" | jq empty 2>/dev/null; then : else services='[]'