[bug-hunter] notify-package-docs-failure can skip commenting on the triggering PR when a commit belongs to multiple PRs

Open Beginner friendly
#18,204 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
github-actions, shell
Domain
ci-cd

Research direction

Start with .github/workflows/notify-package-docs-failure.yml:42-46 and compare its commit-to-PR selection with the PR_NUMBER written in .github/workflows/validate-package-docs.yml:86. Run the minimal reproduction and failing assertion from the issue; done means the triggering PR is recognized when its number appears anywhere in the commit’s PR list.

Written by the indexing model from the issue text.

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:
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:

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

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? | From workflow: Bug Hunter

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

  • expires on Apr 9, 2026, 11:29 AM UTC
Dominant language
Handlebars
Stars
334
Forks
652
Avg merge
1d 22h
Merged PRs (30d)
241

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from elastic/integrations

All issues in elastic/integrations

Similar issues

More DevOps issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.