Skip to content

Commit 9b66746

Browse files
dfa1claude
andcommitted
fix(ci): hydrate script fed slugs to python via stdin, colliding with the heredoc program
The hydrate step ran python via `python - <<'PY'`, which reads the PROGRAM from stdin — so piping the slug list into the same stdin collided: the interpreter either sees an empty sys.stdin (CI: heredoc wins → hydrated=0, printf broken pipe → pipefail exit 1) or tries to execute the slugs as source. Never worked; the conformance workflow's first real runs both died here. Pass the slug list in a temp file (SLUGFILE) and read that instead of sys.stdin, keeping the heredoc as the program. Verified end-to-end against a stub raincloud (under-cap hydrate, over-cap skip, null-size-as-0 all correct). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6e42a30 commit 9b66746

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

scripts/hydrate-raincloud-corpus.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,18 @@ if [ ${#SLUGS[@]} -eq 0 ]; then
6767
fi
6868

6969
mkdir -p "$(dirname "$MANIFEST")"
70-
printf '%s\n' "${SLUGS[@]}" | MAX_MB="$MAX_MB" MANIFEST="$MANIFEST" "$VENV/bin/python" - <<'PY'
70+
71+
# `python - <<'PY'` reads the PROGRAM from stdin, so stdin is unavailable for data:
72+
# piping the slug list into it would collide with the heredoc (the interpreter would
73+
# either execute the slugs as source or see an empty sys.stdin). Hand the slugs over
74+
# in a temp file instead and let the program read that.
75+
SLUGFILE="$(mktemp)"
76+
trap 'rm -f "$SLUGFILE"' EXIT
77+
printf '%s\n' "${SLUGS[@]}" > "$SLUGFILE"
78+
79+
MAX_MB="$MAX_MB" MANIFEST="$MANIFEST" SLUGFILE="$SLUGFILE" "$VENV/bin/python" - <<'PY'
7180
import json
7281
import os
73-
import sys
7482
from importlib import resources
7583
7684
import raincloud
@@ -85,9 +93,12 @@ sizes = {
8593
for slug, entry in snapshot["slugs"].items()
8694
}
8795
96+
with open(os.environ["SLUGFILE"]) as fh:
97+
slugs = [line.strip() for line in fh if line.strip()]
98+
8899
hydrated, skipped = 0, 0
89100
with open(os.environ["MANIFEST"], "w") as manifest:
90-
for slug in (line.strip() for line in sys.stdin if line.strip()):
101+
for slug in slugs:
91102
size = sizes.get(slug, 0)
92103
if max_bytes and size > max_bytes:
93104
print(f"skip {slug}: {size / 1e6:.0f} MB exceeds --max-mb")

0 commit comments

Comments
 (0)