elastic / elastic/integrations
[bug-hunter] notify-package-docs-failure duplicate-check ignores paginated PR comments
- Dominant language
- Handlebars
- Stars
- 333
- Forks
- 647
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 209
Description
## Impact
PRs with more than one page of comments can receive repeated "Package docs validation failed" comments on every failing run. This creates notification spam and hides signal for maintainers/reviewers.
## Reproduction Steps
1. Confirm the workflow duplicate-check logic:
- `.github/workflows/notify-package-docs-failure.yml:49-50`
- It runs:
- `gh api "repos/\$\{REPO}/issues/\$\{PR_NUMBER}/comments" --jq '[.[] | select(.body | contains("Package docs validation failed"))] | length'`
2. Run this new minimal repro script (written for this investigation):
```bash
cat > /tmp/gh-aw/agent/repro_notify_duplicate.sh <<'SH'
#!/usr/bin/env bash
set -euo pipefail
python - <<'PY'
import json
page1=[{"id":i,"body":f"noise comment {i}"} for i in range(1,31)]
page2=[{"id":31,"body":"⚠️ **Package docs validation failed.** Please check the workflow run for details."}]
with open('/tmp/gh-aw/agent/comments_page1.json','w') as f: json.dump(page1,f)
with open('/tmp/gh-aw/agent/comments_all.json','w') as f: json.dump(page1+page2,f)
PY
first_page=$(jq '[.[] | select(.body | contains("Package docs validation failed"))] | length' /tmp/gh-aw/agent/comments_page1.json)
all_pages=$(jq '[.[] | select(.body | contains("Package docs validation failed"))] | length' /tmp/gh-aw/agent/comments_all.json)
printf 'EXISTING from first page query: %s\n' "$first_page"
printf 'EXISTING from all pages query: %s\n' "$all_pages"
if [[ "$first_page" == "0" && "$all_pages" == "1" ]]; then
echo 'BUG: current workflow duplicate-check can post duplicate PR comments when the existing comment is past page 1.'
exit 1
fi
SH
chmod +x /tmp/gh-aw/agent/repro_notify_duplicate.sh
/tmp/gh-aw/agent/repro_notify_duplicate.sh
```
## Expected vs Actual
**Expected:** If any existing docs-failure comment exists in PR comments (across all pages), workflow should not post another one.
**Actual:** The query checks only the first API page, so it returns 0 when the matching comment is on a later page, and workflow would post a duplicate.
Observed output:
```text
EXISTING from first page query: 0
EXISTING from all pages query: 1
BUG: current workflow duplicate-check can post duplicate PR comments when the existing comment is past page 1.
```
## Failing Test
```bash
#!/usr/bin/env bash
set -euo pipefail
python - <<'PY'
import json
page1=[{"id":i,"body":f"noise comment {i}"} for i in range(1,31)]
page2=[{"id":31,"body":"⚠️ **Package docs validation failed.** Please check the workflow run for details."}]
with open('/tmp/gh-aw/agent/comments_page1.json','w') as f: json.dump(page1,f)
with open('/tmp/gh-aw/agent/comments_all.json','w') as f: json.dump(page1+page2,f)
PY
first_page=$(jq '[.[] | select(.body | contains("Package docs validation failed"))] | length' /tmp/gh-aw/agent/comments_page1.json)
all_pages=$(jq '[.[] | select(.body | contains("Package docs validation failed"))] | length' /tmp/gh-aw/agent/comments_all.json)
[[ "$first_page" == "0" && "$all_pages" == "1" ]] && exit 1
```
## Evidence
- `.github/workflows/notify-package-docs-failure.yml:49-50` uses `gh api .../comments` without pagination when counting existing comments.
- `.github/workflows/notify-package-docs-failure.yml:51-53` posts a new comment whenever that count is `0`.
- GitHub list-comments APIs are paginated; without pagination, comments beyond page 1 are not considered by this check.
> [!NOTE]
>
> 🔒 Integrity filtering filtered 1 item
>
> Integrity filtering activated and filtered the following item 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".)
>
>
---
[What is this?](https://ela.st/github-ai-tools) | [From workflow: Bug Hunter](https://github.com/elastic/integrations/actions/runs/24078722085)
Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
> - [x] expires on Apr 14, 2026, 11:32 AM UTC
Contributor guide
Assessment
This issue has not been assessed yet.