elastic / elastic/integrations
[bug-hunter] notify-package-docs-failure can skip commenting on the triggering PR when a commit belongs to multiple PRs
- Dominant language
- Handlebars
- Stars
- 333
- Forks
- 647
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 209
Description
## Impact
When package docs validation fails, the notification workflow can silently skip posting a comment on the triggering PR if the same `head_sha` is associated with multiple PRs. This hides actionable failure feedback from maintainers/reviewers and weakens the intended PR gate UX.
## Reproduction Steps
1. Observe the workflow logic in `.github/workflows/notify-package-docs-failure.yml`:
- It reads the triggering PR number from the artifact (`PR_NUMBER`).
- It fetches PRs for the commit SHA and selects only the first one: `--jq '.[0].number'`.
- It exits early when `PR_NUMBER != ACTUAL_PR`.
2. Run this minimal reproduction script:
```bash
python - <<'PY'
import json
def should_comment(pr_number, pulls_json):
actual_pr = str(json.loads(pulls_json)[0]["number"]) if json.loads(pulls_json) else ""
return pr_number == actual_pr, actual_pr
# Repro: same HEAD SHA associated with multiple PRs; artifact points to triggering PR=42
pr_number = "42"
pulls = '[{"number": 17}, {"number": 42}]'
comment, actual = should_comment(pr_number, pulls)
print(f"artifact_pr={pr_number}")
print(f"api_pulls={pulls}")
print(f"selected_actual_pr={actual}")
print(f"comment_posted={comment}")
if not comment:
print("BUG: workflow would exit early and skip commenting on the triggering PR")
PY
```
## Expected vs Actual
**Expected:** If the artifact PR number is present in the commit→PR list, the workflow should comment on that triggering PR.
**Actual:** The workflow uses only the first PR from the list (`.[0].number`), so it exits early when ordering does not match the artifact PR. Reproduction output:
```text
artifact_pr=42
api_pulls=[{"number": 17}, {"number": 42}]
selected_actual_pr=17
comment_posted=False
BUG: workflow would exit early and skip commenting on the triggering PR
```
## Failing Test
```python
import json
def should_comment(pr_number, pulls_json):
actual_pr = str(json.loads(pulls_json)[0]["number"]) if json.loads(pulls_json) else ""
return pr_number == actual_pr
assert should_comment("42", '[{"number": 17}, {"number": 42}]')
```
The assertion fails because only the first PR is considered.
## Evidence
- `.github/workflows/notify-package-docs-failure.yml:42-46`
- `ACTUAL_PR=$(gh api "repos/\$\{REPO}/commits/\$\{HEAD_SHA}/pulls" --jq '.[0].number' ...)`
- `if [ "$PR_NUMBER" != "$ACTUAL_PR" ]; then ... exit 0`
- `.github/workflows/validate-package-docs.yml:86`
- The artifact explicitly stores the triggering PR number (`echo "\$\{PR_NUMBER}" > .../pr_number`).
This mismatch in selection strategy makes notification delivery depend on API ordering rather than the known triggering PR.
> [!NOTE]
>
> 🔒 Integrity filtering filtered 6 items
>
> Integrity filtering activated and filtered the following items during workflow execution.
> This happens when a tool call accesses a resource that does not meet the required integrity or secrecy level of the workflow.
>
> - issue:elastic/integrations#unknown (`search_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/integrations#17857 (`issue_read`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/integrations#17875 (`issue_read`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/integrations#18099 (`issue_read`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/integrations#18068 (`issue_read`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/integrations#18180 (`issue_read`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
>
>
---
[What is this?](https://ela.st/github-ai-tools) | [From workflow: Bug Hunter](https://github.com/elastic/integrations/actions/runs/23897831115)
Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
> - [x] expires on Apr 9, 2026, 11:29 AM UTC
Contributor guide
Assessment
This issue has not been assessed yet.