Skip to content

fix(ci): add non-blocking reminder for non-closing issue references in PRs - #2351

Merged
carlos-alm merged 2 commits into
mainfrom
fix/issue-2181-closing-keyword-check
Aug 8, 2026
Merged

carlos-alm merged 2 commits into
mainfrom
fix/issue-2181-closing-keyword-check

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

Closes #2181

Three issues (#1763, #1867, #1888) were already fully fixed and merged to main but stayed open because the merging PR used "Refs #N" instead of a closing keyword — which looks like a valid reference but does not trigger GitHub's auto-close on merge. Nothing previously caught this.

Fix

A hard-failing CI gate isn't the right shape here: a non-closing reference (Refs #N, Related #N, a partial fix) is often intentional, and text alone can't distinguish that from a genuine mistake. Instead:

  • New .github/workflows/closing-keyword-check.yml: scans the PR body for issue references using a non-closing phrase (Refs #N, Related #N, related to #N, see #N, or a bare (#N)) that have no closing keyword (closes/fixes/resolves + variants) for that same issue number, and posts (or clears, on later edits) a single informational PR comment. It never fails the build — it only makes the gap visible for a human to confirm.
  • Uses pull_request_target rather than pull_request: the check only reads the trusted event payload's body field — no checkout, no code execution — so this is safe without the workflow_run split codegraph-impact-comment.yml uses for its riskier (code-executing) case, and it also works correctly on fork PRs, which get a read-only token under plain pull_request.
  • Clarified the existing "Related issues" hint in .github/PULL_REQUEST_TEMPLATE.md to spell out that Refs/Related won't auto-close the issue — addressing the PR-template-reminder option directly, as defense in depth alongside the automated check.

Test plan

  • Verified the regex/dedup logic locally against 8 cases (closes-only, refs-only, refs+closes for the same number, "related to", bare parens, lowercase "fixes", mixed multi-issue body, no references at all) — all produce the expected flagged set.
  • python3 -c "import yaml; yaml.safe_load(...)" — valid YAML.
  • actionlint .github/workflows/closing-keyword-check.yml — zero findings.

…n PRs

Closes #2181

Three issues (#1763, #1867, #1888) were already fully fixed and merged to
main but stayed open because the merging PR used "Refs #N" instead of a
closing keyword — which looks like a valid reference but does not trigger
GitHub's auto-close on merge. Nothing previously caught this.

A hard-failing CI gate isn't the right shape here: a non-closing reference
("Refs #N", "Related #N", partial fixes) is often intentional, and text
alone can't distinguish that from a mistake. Added a new
closing-keyword-check.yml workflow that scans the PR body for issue
references using a non-closing phrase with no closing keyword for the same
number, and posts (or clears) a single informational PR comment — it never
fails the build, it just makes the gap visible for a human to confirm.
Uses pull_request_target since the check only reads the trusted event
payload's body field (no checkout, no code execution), so it also works on
fork PRs, unlike plain pull_request which gets a read-only token there.

Also clarified the existing "Related issues" hint in
.github/PULL_REQUEST_TEMPLATE.md to spell out that Refs/Related won't
auto-close, addressing the PR-template-reminder option directly.
@greptile-apps

greptile-apps Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a non-blocking workflow that detects non-closing issue references in pull-request descriptions and manages a single informational reminder comment.

  • Scans PR bodies for referenced issues that lack a corresponding closing keyword.
  • Creates, updates, or removes a bot-authored reminder without failing CI.
  • Clarifies closing-keyword behavior in the pull-request template.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the prior foreign-comment mutation issue is fixed by requiring both the unique marker and the github-actions[bot] author.

Important Files Changed

Filename Overview
.github/workflows/closing-keyword-check.yml Adds the informational issue-reference scanner and safely restricts reminder mutation to the workflow’s uniquely marked, bot-authored comment.
.github/PULL_REQUEST_TEMPLATE.md Clarifies which issue-reference phrases do and do not automatically close issues.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Event[PR opened, edited, or reopened] --> Scan[Scan PR body]
  Scan --> Missing{Non-closing references without matching closing keywords?}
  Missing -->|Yes| Existing{Own bot reminder exists?}
  Existing -->|Yes| Update[Update reminder]
  Existing -->|No| Create[Create reminder]
  Missing -->|No| Old{Own bot reminder exists?}
  Old -->|Yes| Delete[Delete reminder]
  Old -->|No| Done[No action]
Loading

Reviews (2): Last reviewed commit: "fix(ci): restrict closing-keyword-check ..." | Re-trigger Greptile

repo: context.repo.repo,
issue_number: prNumber,
});
const existing = comments.find((c) => c.body.includes(marker));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Marker permits foreign comment mutation

When a PR participant posts a comment containing <!-- closing-keyword-check --> and the PR is edited or reopened, the workflow selects that comment without checking its author and then overwrites or deletes it instead of managing only its own reminder. How this was verified: The selected comment is determined only by c.body.includes(marker) and passed directly to the update or delete API.

Fix in Claude Code

…d comments

Greptile flagged (PR #2351) that matching an existing comment purely by
marker text lets a PR participant plant the marker in their own comment
and have a later edit/reopen event overwrite or delete it. Restrict the
lookup to comments authored by github-actions[bot].

Filed #2352 for the identical pre-existing pattern in
codegraph-impact-comment.yml, out of scope for this PR.
@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

@carlos-alm
carlos-alm merged commit 27100b9 into main Aug 8, 2026
23 checks passed
@carlos-alm
carlos-alm deleted the fix/issue-2181-closing-keyword-check branch August 8, 2026 10:28
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recurring pattern: merged PRs using "Refs #N" instead of "Closes #N" leave already-fixed issues open

1 participant