Skip to content

Commit 1141cca

Browse files
authored
Fix: Replace head with jq limit() to prevent broken pipe error (#252)
- Use jq's limit() function instead of shell's head to avoid broken pipe errors - Pass LIMIT as --arg to jq and convert with tonumber inside the limit() call - Fixes 'jq: error: writing output failed: Broken pipe' errors in CI/CD - More efficient: avoids creating pipe to head command - All 22 tests pass
1 parent 8d259ff commit 1141cca

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

check-missing-versions.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,14 @@ SKIP_VERSIONS_JSON=$(echo "$SKIP_VERSIONS" | jq -R . | jq -s .)
122122
# $skip | index($v) - Check if $v is in SKIP_VERSIONS array
123123
# Returns index (0+) if found, null if not
124124
# | not - Invert: keep version only if NOT in skip list
125-
# .[] - Unpack array to individual lines
126-
# head -${LIMIT} - Limit to first N versions
125+
# limit($limit; ..[]) - Limit to first N versions using jq (avoids broken pipe)
126+
# Note: Using jq's limit() instead of head to avoid broken pipe error when limiting output
127127
PRUNED_VERSIONS=()
128128
while IFS= read -r version; do
129129
[[ -n "$version" ]] && PRUNED_VERSIONS+=("$version")
130130
done < <(curl -fsSLo- --compressed https://nodejs.org/dist/index.json |
131-
jq -r --argjson skip "$SKIP_VERSIONS_JSON" \
132-
'[.[].version | ltrimstr("v")] | map(select(. as $v | $skip | index($v) | not)) | .[]' |
133-
head -"${LIMIT}")
131+
jq -r --argjson skip "$SKIP_VERSIONS_JSON" --arg limit "$LIMIT" \
132+
'[.[].version | ltrimstr("v")] | map(select(. as $v | $skip | index($v) | not)) | limit($limit | tonumber; .[])')
134133

135134
# Check which versions from PRUNED_VERSIONS are missing from Docker Hub.
136135
# Run check_tag_with_retry in parallel (one background job per version) for efficiency.

0 commit comments

Comments
 (0)