Skip to content

Link the issues a pull request names in its description - #184

Merged
imshashank merged 2 commits into
mainfrom
feat/link-pr-body-issues
Aug 8, 2026
Merged

imshashank merged 2 commits into
mainfrom
feat/link-pr-body-issues

Conversation

@imshashank

@imshashank imshashank commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

The gap, measured

The GitHub integration is wired end to end and working. Production has 2 installations, 26 repositories discovered, 5 linked to projects, 4 watched, and the webhook has processed 568 pull_request deliveries, 1090 check_suite, and 4475 check_run.

It has produced zero issue links.

The reason is narrow. applyGithubEvent reads issue identifiers from exactly two places:

extractIssueIdentifiers(`${event.pullRequest.headRef} ${event.pullRequest.title}`)

The branch name and the title. Not the description. And the webhook payload's body was never parsed off the wire at all, so it could not have been read even by accident.

That means "Fixes NOV-172" written in a pull request description links nothing, which is both where people actually put it and what GitHub's own closing keywords key off. The four watched repositories name branches after the change rather than the issue, so nothing has ever matched.

The change

body is parsed (capped at 64k, null coalesced to empty), carried on NormalizedPullRequest, and fed to the same extractor alongside the branch and title. No new permission is needed: the body arrives in the webhook payload that is already being delivered.

Tests

Two in apply.test.ts, both watched failing first:

  • an issue named only in the description gets linked. Dropping body from the extractor input fails exactly this one.
  • a pull request naming no identifier anywhere, description included, still links nothing. This is the guard against the change turning into a match-everything.

Full services suite: 503 pass, 0 fail. Typecheck and every verify guard clean.

Greptile Summary

The PR parses pull request descriptions and limits issue linking to keyword-based declarations outside several non-prose Markdown constructs. The current cleanup remains incomplete for indented Markdown code blocks.

  • Adds normalized pull request body handling to GitHub webhook events.
  • Extracts explicitly declared issue identifiers from descriptions.
  • Adds utility and integration coverage for declarations, comments, quotes, and fenced or inline code.

Confidence Score: 4/5

The PR is not yet safe to merge because declarations inside indented Markdown code blocks can still link and transition unrelated issues.

The attempted context-sensitive extraction leaves a standard Markdown code-block form unfiltered, so the previously reported incorrect-linking behavior remains reachable.

Files Needing Attention: packages/shared/src/utils/index.ts, packages/services/src/github/apply.ts

Important Files Changed

Filename Overview
packages/services/src/github/apply.ts Combines title and branch identifiers with body declarations before applying existing issue-linking and workflow side effects.
packages/services/src/github/index.ts Validates and normalizes the pull request body from pull request and review webhook payloads.
packages/shared/src/utils/index.ts Adds declaration-aware identifier extraction, but its Markdown filtering leaves indented code blocks eligible for matching.
packages/services/tests/github/apply.test.ts Adds end-to-end coverage for declarations and several incidental contexts, but does not cover indented code blocks.
packages/shared/tests/utils/utils.test.ts Covers keyword matching and several excluded Markdown constructs without exercising indented code blocks.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[GitHub webhook] --> B[Normalize pull request body]
  B --> C[Remove recognized non-prose Markdown]
  C --> D[Extract keyword-based issue declarations]
  D --> E[Load matching issues]
  E --> F[Create PR links and transition issue state]
  G[Indented code block] -->|Not removed| D
Loading

Fix All in Claude Code

Prompt To Fix All With AI
### Issue 1
packages/shared/src/utils/index.ts:171-180
**Indented code declarations still link**

When a pull request description contains an indented Markdown code block such as `    Fixes ENG-3`, `withoutNonProse` leaves the declaration intact, so `declaredIssueIdentifiers` links the pull request to that issue and can transition the unrelated issue's workflow state.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (2): Last reviewed commit: "fix(github): only link issues a descript..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Identifiers were only read from the branch name and the title, so a
pull request whose description says "Fixes NOV-172" linked nothing.
That is where people put it, and it is what GitHub's own closing
keywords key off, so the common case was the one that did not work.

Evidence from production: 568 pull_request deliveries processed, and
zero git links, across four watched repositories whose branches are
named after the change rather than the issue.

The webhook payload's body was not even parsed. It is now, capped at
64k, null coalesced to empty, and fed to the same extractor alongside
the branch and title.
@imshashank
imshashank requested a review from pulkitxm as a code owner August 8, 2026 11:14
@vercel

vercel Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
orbit Ready Ready Preview Aug 8, 2026 12:53pm

Request Review

@github-actions github-actions Bot added tests Test coverage and test infrastructure area: integrations GitHub, Slack and webhooks labels Aug 8, 2026
@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

GitHub pull request normalization now preserves nullable bodies as strings. Issue identifier extraction scans the body in addition to the branch and title. Tests cover identifiers found only in descriptions and descriptions without identifiers.

Changes

GitHub body issue linking

Layer / File(s) Summary
Normalize pull request bodies
packages/services/src/github/index.ts
The pull request schema accepts nullable bodies. normalizePullRequest converts missing or null bodies to an empty string. NormalizedPullRequest exposes body as a required string.
Extract and test body identifiers
packages/services/src/github/apply.ts, packages/services/tests/github/apply.test.ts
extractIssueIdentifiers scans the pull request body. Test fixtures accept optional bodies, and tests cover matching and non-matching descriptions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: pulkitxm

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description clearly explains the GitHub body parsing and issue-linking changes, with supporting tests and validation results.
Title check ✅ Passed The title clearly and concisely describes the main change: linking issues named in pull request descriptions.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/link-pr-body-issues

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Comment thread packages/services/src/github/apply.ts Resolved
Reading the whole body for bare identifiers was too blunt. A pull
request template carrying "Fixes ENG-3" as its example, a code block
demonstrating a branch name, or a quoted reply would each have linked a
stranger's issue, moved it to In Progress, and notified everybody
watching it.

The branch and the title keep matching a bare identifier, because both
are short and deliberate. The description now needs a linking keyword,
the set GitHub already trains people on plus a few Linear uses, and is
read with fenced blocks, inline code, html comments and quoted lines
stripped first.

Eight unit tests on the extractor and two on the event path, covering
each shape that would previously have produced a false link.
Comment on lines +171 to +180
export function withoutNonProse(text: string): string {
return text
.replace(/```[\s\S]*?```/g, ' ')
.replace(/~~~[\s\S]*?~~~/g, ' ')
.replace(/`[^`\n]*`/g, ' ')
.replace(/<!--[\s\S]*?-->/g, ' ')
.split('\n')
.filter((line) => !/^\s*>/.test(line))
.join('\n');
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Indented code declarations still link

When a pull request description contains an indented Markdown code block such as Fixes ENG-3, withoutNonProse leaves the declaration intact, so declaredIssueIdentifiers links the pull request to that issue and can transition the unrelated issue's workflow state.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/shared/src/utils/index.ts
Line: 171-180

Comment:
**Indented code declarations still link**

When a pull request description contains an indented Markdown code block such as `    Fixes ENG-3`, `withoutNonProse` leaves the declaration intact, so `declaredIssueIdentifiers` links the pull request to that issue and can transition the unrelated issue's workflow state.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

@imshashank
imshashank merged commit 0af9d67 into main Aug 8, 2026
11 checks passed
@imshashank
imshashank deleted the feat/link-pr-body-issues branch August 8, 2026 13:00

This branch was successfully deployed

1 active deployment
Preview — 60dedc8c Deployed Aug 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: integrations GitHub, Slack and webhooks tests Test coverage and test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant