Skip to content

Fix partner-impact Slack notice crashing when a PR changes more than 20 partner files#8891

Merged
hua7450 merged 1 commit into
PolicyEngine:mainfrom
hua7450:fix-partner-notice-truncation
Jul 4, 2026
Merged

Fix partner-impact Slack notice crashing when a PR changes more than 20 partner files#8891
hua7450 merged 1 commit into
PolicyEngine:mainfrom
hua7450:fix-partner-notice-truncation

Conversation

@hua7450

@hua7450 hua7450 commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

The partner-api-impact-notice.yaml workflow (Slack notice when partner contract tests change) crashes on any PR that changes more than 20 partner files — first triggered by #8890 (172 changed partner files), which consequently got no Slack notice.

Root cause

file_list=$(printf '%s\n' "${CHANGED_FILES}" | sed '/^$/d' | head -20 | sed 's/^/- /')

head -20 exits after emitting 20 lines, closing the pipe's read end. GNU sed flushes its output in ~4KB chunks, so with enough files its next write() hits the closed pipe. The Actions runner ignores SIGPIPE, so sed gets EPIPE, prints sed: couldn't write 114 items to stdout: Broken pipe, and exits 4 — which set -euo pipefail promotes to a job failure. Reproduced deterministically: a producer still writing after the consumer exits fails with 141/4 under pipefail; the awk form below cannot fail this way because awk always reads to EOF.

Fix

  • Replace the head -20 pipeline with awk 'NF && ++n <= 20 { print "- " $0 }' — identical output (blank lines dropped, first 20 files, - prefix), but the consumer reads all input, so no producer ever receives SIGPIPE.
  • Make the list heading accurate: Showing first 20: only when the list is actually truncated, Changed files: otherwise.

Message rendering dry-run against #8890's real 172-file list produces the expected notice (Changed partner files: 172, first 20 listed, ...and 152 more).

Note: this workflow runs on pull_request_target, so the fix only takes effect after merging to main; #8890's red check clears on its next event after that.

Test plan

🤖 Generated with Claude Code

…20 partner files

head -20 exits after 20 lines; GNU sed flushes output in 4KB chunks, so
with enough changed files its next write hits the closed pipe and fails
(exit 4 under the Actions runner's ignored SIGPIPE), which
set -euo pipefail promotes to a job failure. Replace the head pipeline
with an awk consumer that reads all input to EOF, keeping the same
top-20 truncation. Also make the list heading accurate when 20 or fewer
files change.

First triggered by PolicyEngine#8890 (172 changed partner files), which therefore
got no Slack notice.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hua7450 hua7450 merged commit 37f3b93 into PolicyEngine:main Jul 4, 2026
27 checks passed
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.

1 participant