Skip to content

fix: add word boundary to LINK_REGEX to prevent false positive issue …#138

Merged
MkDev11 merged 4 commits into
MkDev11:mainfrom
web-dev0521:fix/pr-linking-word-boundary
May 25, 2026
Merged

fix: add word boundary to LINK_REGEX to prevent false positive issue …#138
MkDev11 merged 4 commits into
MkDev11:mainfrom
web-dev0521:fix/pr-linking-word-boundary

Conversation

@web-dev0521
Copy link
Copy Markdown
Contributor

@web-dev0521 web-dev0521 commented May 22, 2026

Summary

Adds a \b word boundary assertion before the closing-keyword group in LINK_REGEX (src/lib/pr-linking.ts) to prevent substrings like bugfix, hotfix, and discloses from triggering false-positive issue links that persist indefinitely in the pr_issue_links table.

Related Issues

Closes #137

Type of Change

  • Bug fix

Testing

  • pnpm build passes
  • Manual browser smoke test (for UI changes)
  • N/A — docs / config only

Checklist

  • Self-reviewed the diff
  • Follows existing code patterns and naming
  • No unrelated changes included
  • Documentation updated if behavior changed

Summary by CodeRabbit

  • Bug Fixes
    • Improved accuracy of automatic issue linking by tightening how the system recognizes issue references, reducing false positives.
    • Performed a one-time cleanup to remove previously created incorrect links so issue lists now reflect only legitimate references.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1bf35d4b-3f6a-4b39-93bd-ff3ad8b590f7

📥 Commits

Reviewing files that changed from the base of the PR and between 616292c and 0f0da83.

📒 Files selected for processing (1)
  • src/lib/db.ts

📝 Walkthrough

Walkthrough

LINK_REGEX is updated to require a word boundary before closing keywords, and a one-time guarded DB migration recomputes links with both the old and new regexes to delete pr_issue_links rows that were false positives under the previous (boundaryless) pattern.

Changes

Issue Link Detection Fix

Layer / File(s) Summary
Link regex word boundary
src/lib/pr-linking.ts
LINK_REGEX now includes a leading \b before the `close
Migration helpers to find legacy false positives
src/lib/db.ts
Adds constants and helper functions that compute same-repo issue numbers from PR titles/bodies using both the legacy boundaryless regex and the corrected regex, and build the set of links that should be deleted.
One-time migration run in getDb()
src/lib/db.ts
Adds a guarded migration in getDb() that checks PRAGMA user_version, purges only links present under the old extraction, updates user_version, and logs how many rows were removed.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

A rabbit hops through code and logs the fix,
“No more stray links from 'bugfix' tricks.
I trimmed the regex, pruned the old ties,
Cleaned up the DB with careful eyes.
Hooray — tidy links and clearer skies!” 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a word boundary to LINK_REGEX to prevent false positive issue links.
Linked Issues check ✅ Passed The PR fully addresses issue #137 by fixing the regex pattern and adding a data migration to remove already-persisted false-positive entries.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objectives: regex fix in pr-linking.ts and cleanup migration in db.ts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/lib/db.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


Comment @coderabbitai help to get the list of available commands and usage tips.

@MkDev11
Copy link
Copy Markdown
Owner

MkDev11 commented May 24, 2026

The regex change fixes new parsing, but it does not repair already-persisted false-positive pr_issue_links.

refresh.ts still treats pr_issue_links as append-only (INSERT OR IGNORE), and backfillPrIssueLinksIfNeeded() returns immediately when a repo already has any link rows. That means bad rows previously created by bugfix #N, hotfix #N, discloses #N, etc. remain in SQLite after deploy, so affected issues stay misclassified as completed.

Please add a safe cleanup/migration path for existing stale body-regex links, or otherwise explain why existing contaminated DBs are out of scope. Until then, Closes #137 is not accurate.

The word-boundary regex fix only stops NEW bad links; existing rows
created by the old boundaryless pattern (e.g. "bugfix MkDev11#42",
"discloses MkDev11#42") persist because pr_issue_links is append-only and the
per-repo backfill is gated on the table being empty.

Add a one-shot data migration in getDb(), guarded by PRAGMA user_version
so it runs exactly once per database file. For every cached PR it
recomputes same-repo links under both the old (boundaryless) and new
(fixed) patterns and deletes only the difference. GraphQL/sidebar links
are untouched: a PR with no closing keyword yields an empty old-match
set and is skipped entirely, and any link still produced by the fixed
regex is retained.
@web-dev0521
Copy link
Copy Markdown
Contributor Author

I just added a one-time migration that re-scans cached PRs and removes the bad links the old regex created.
It only runs once, and leaves GraphQL/sidebar links alone.

@MkDev11 MkDev11 merged commit 1d0b23d into MkDev11:main May 25, 2026
4 checks passed
@web-dev0521
Copy link
Copy Markdown
Contributor Author

Thank you, @MkDev11 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: LINK_REGEX missing word boundary causes false pr_issue_links entries (bugfix/hotfix/discloses)

2 participants