Skip to content

fix: eliminate piped while loops in token optimizer workflows#24354

Merged
pelikhan merged 1 commit intomainfrom
fix/token-workflow-pipefail-consistency
Apr 3, 2026
Merged

fix: eliminate piped while loops in token optimizer workflows#24354
pelikhan merged 1 commit intomainfrom
fix/token-workflow-pipefail-consistency

Conversation

@lpcox
Copy link
Copy Markdown
Collaborator

@lpcox lpcox commented Apr 3, 2026

Follow-up to PR #24350 — applies the same pipefail-safe patterns to the remaining token workflows.

Changes

Optimizer workflows (copilot + claude)

Replace find | head -1 | while read piped pattern with command substitution:

# Before (SIGPIPE risk under pipefail)
find ... | head -1 | while read -r f; do cp "$f" ...; done

# After (safe)
FOUND_MD=$(find ... | head -1 || true)
if [ -n "$FOUND_MD" ]; then cp "$FOUND_MD" ...; fi

Claude analyzer consistency fix

Align jq invocation with copilot variant:

  • Use []?.databaseId (optional object access) instead of .[].databaseId
  • Add 2>/dev/null || true error handling

Affected workflows

  • copilot-token-optimizer.md
  • claude-token-optimizer.md
  • claude-token-usage-analyzer.md (jq consistency fix only)

Replace find | head -1 | while read piped pattern with command
substitution in copilot-token-optimizer and claude-token-optimizer
to avoid potential SIGPIPE under set -euo pipefail.

Also fix claude-token-usage-analyzer jq line to match copilot variant:
use []?.databaseId (optional object access) with 2>/dev/null || true.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 3, 2026 18:50
@pelikhan pelikhan merged commit 1cbec99 into main Apr 3, 2026
87 of 92 checks passed
@pelikhan pelikhan deleted the fix/token-workflow-pipefail-consistency branch April 3, 2026 18:55
@lpcox lpcox review requested due to automatic review settings April 3, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants