Skip to content

[Bug] extractIssueNumbers bare #N alternative matches any issue reference, awarding XP for PRs that mention but do not fix an issue #217

@anshul23102

Description

@anshul23102

Summary

The regex used in extractIssueNumbers (inside src/inngest/functions/process-pr-event.ts) contains a second alternative that matches any bare #N token. As a result, a PR body such as "Related to #42" or "See discussion in #7" triggers the same XP award path as "Fixes #42", even though no issue is actually being closed.

Affected File

src/inngest/functions/process-pr-event.ts

Root Cause

const ISSUE_REF = /(?:close[sd]?|fixe[sd]?|resolve[sd]?)\s+#(\d+)|#(\d+)/gi;

The regex has two alternatives separated by |:

  1. (?:close[sd]?|fixe[sd]?|resolve[sd]?)\s+#(\d+) - closing keywords followed by an issue number (correct intent)
  2. #(\d+) - any bare #N reference anywhere in the PR body (unintended)

Wherever extractIssueNumbers passes results to tryLinkByIssueRef, the second alternative causes every issue mentioned in passing to enter the XP award pipeline alongside genuinely resolved issues.

Impact

  • Any PR body that references an issue number for context (code review discussion, related-work links, changelog notes) will incorrectly trigger XP awards for that issue.
  • On a busy repository with many cross-references, this inflates XP balances for all participants systematically and silently.
  • Because the idempotency key is (user_id, source, ref_id), the erroneous award is committed on first merge and cannot be cleanly corrected by re-running the event.

Steps to Reproduce

  1. Open a PR with body: Refactors the auth flow. See #10 for background.
  2. Merge the PR (no closing keyword present).
  3. Observe XP awarded for issue fix(webhook): surface insert error details #10 as if the PR had resolved it.

Expected Behaviour

Only closing-keyword matches should produce issue links. The second bare-reference alternative should be removed:

const ISSUE_REF = /(?:close[sd]?|fixe[sd]?|resolve[sd]?)\s+#(\d+)/gi;

If cross-repository closing syntax (owner/repo#N) is needed in future, it should be added explicitly with the same keyword guard rather than by broadening the bare-ref alternative.

Severity

High - Silent, systematic XP inflation on every merged PR that mentions an issue number in passing. The impact compounds over time as the repository grows.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions