Skip to content

Commit 4d69b4b

Browse files
FeodorFitsnerclaude
andcommitted
fix(ci): strip dart-run noise via byte-level { extraction, not line-based sed
Last run uncovered the actual prefix: `dart run` joins "Running build hooks..." (sometimes printed multiple times) onto the same line as our JSON's opening `{`, so my line-based `sed -n '/^{/,$p'` matched no line and ate the JSON entirely. Replace it with `json="{${raw#*\{}"` — bash parameter expansion that extracts from the first `{` byte forward, regardless of newlines. Guard the empty-output case explicitly so the error message is unambiguous. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f10dc84 commit 4d69b4b

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

.github/actions/resolve-python-vars/action.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,25 @@ runs:
2424
echo "::error::SERIOUS_PYTHON_VERSION is not set in env."
2525
exit 1
2626
fi
27-
flutter pub get
28-
# Capture stdout+stderr of `dart run` so any failure prose is visible
29-
# for diagnosis. `dart run` writes "Building package executable..." to
30-
# stdout on a cold cache ahead of our JSON; strip everything before
31-
# the opening `{` so `jq` sees only the document.
27+
flutter pub get >/dev/null
28+
# `dart run` writes mixed noise to stdout on a cold cache —
29+
# "Building package executable...", "Running build hooks..." — and
30+
# the build-hook line gets joined to our JSON's opening `{` with no
31+
# newline, so line-based sed patterns like `^{` miss everything.
32+
# Strip from the byte-level first `{` forward instead. stderr is
33+
# captured alongside stdout so any genuine dart error is visible.
3234
raw=$(dart run serious_python:main version --json 2>&1)
33-
printf '%s\n' "--- raw output from dart run ---"
34-
printf '%s\n' "$raw"
35-
printf '%s\n' "--- end raw output ---"
36-
json=$(printf '%s\n' "$raw" | sed -n '/^{/,$p')
35+
if [[ "$raw" != *"{"* ]]; then
36+
echo "::error::dart run produced no JSON for SERIOUS_PYTHON_VERSION=${SERIOUS_PYTHON_VERSION}"
37+
printf '%s\n' "$raw"
38+
exit 1
39+
fi
40+
json="{${raw#*\{}"
3741
full=$(printf '%s\n' "$json" | jq -r ".python_releases.\"${SERIOUS_PYTHON_VERSION}\".standalone_version")
3842
date=$(printf '%s\n' "$json" | jq -r ".python_releases.\"${SERIOUS_PYTHON_VERSION}\".python_build_release_date")
3943
if [[ -z "$full" || "$full" == "null" || -z "$date" || "$date" == "null" ]]; then
4044
echo "::error::serious_python:main version --json did not return values for SERIOUS_PYTHON_VERSION=${SERIOUS_PYTHON_VERSION}"
45+
printf '%s\n' "$json"
4146
exit 1
4247
fi
4348
echo "SERIOUS_PYTHON_FULL_VERSION=$full" >> "$GITHUB_ENV"

0 commit comments

Comments
 (0)