fix: replace piped while loops with temp files to avoid pipefail SIGPIPE#24350
Merged
fix: replace piped while loops with temp files to avoid pipefail SIGPIPE#24350
Conversation
The token usage analyzer workflows use set -euo pipefail which causes jq | head | while read pipelines to fail with exit 141 (SIGPIPE) when head closes the pipe early, silently aborting artifact downloads. Write to temp files first, then read from them in while loops. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Copilot/Claude token usage analyzer workflows to avoid set -euo pipefail failures caused by piped while read loops during artifact download/merge.
Changes:
- Reworked artifact download loops to read run IDs from a temp file rather than
... | while read. - Reworked JSONL merge loops to read file paths from a temp file rather than
find ... | while read. - Regenerated the corresponding compiled/locked workflow YAMLs to reflect the template changes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| .github/workflows/copilot-token-usage-analyzer.md | Uses temp files for run-id and JSONL file iteration in bash steps. |
| .github/workflows/copilot-token-usage-analyzer.lock.yml | Regenerated lockfile reflecting the updated bash step logic. |
| .github/workflows/claude-token-usage-analyzer.md | Uses temp files for run-id and JSONL file iteration in bash steps. |
| .github/workflows/claude-token-usage-analyzer.lock.yml | Regenerated lockfile reflecting the updated bash step logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The token usage analyzer workflows use
set -euo pipefailin their bash steps. The patternjq | head -50 | while readcausesjqto receive SIGPIPE (exit 141) whenheadcloses the pipe early. Withpipefail, this propagates as a pipeline failure, silently aborting the artifact download loop.Discovered while debugging run 23953754099 which failed with exit code 5 after PR #24335 fixed the
./gh-awbinary issue.Fix
Replace piped
jq | head | while readandfind | while readloops with a temp file approach:jq ... > /tmp/.../run-ids.txtwhile read ... done < /tmp/.../run-ids.txtThis avoids SIGPIPE entirely since
jqwrites to a file, not a pipe.Affected workflows
copilot-token-usage-analyzer.md(2 pipelines fixed)claude-token-usage-analyzer.md(2 pipelines fixed)