Skip to content

fix(ten-427): fall back to PR branch/title for TEN issue matching#16

Merged
lavie merged 1 commit into
ten-334-github-webhook-dispatcherfrom
ten-427-webhook-pr-fallback
May 6, 2026
Merged

fix(ten-427): fall back to PR branch/title for TEN issue matching#16
lavie merged 1 commit into
ten-334-github-webhook-dispatcherfrom
ten-427-webhook-pr-fallback

Conversation

@marvin-tensorleap
Copy link
Copy Markdown
Collaborator

Why this change exists

When an agent opens a PR without backfilling the GitHub ref (e.g. tensorleap/paperclip#15) into the issue description, findTenIssue's text search finds nothing and creates a spurious triage issue (like TEN-425) instead of waking the real assignee. This happened on Assaf's review of PR #15, which belongs to TEN-334 — the dispatcher couldn't connect the two and opened a triage issue.

Tracked in TEN-427. Follow-up to #15.

How this PR fixes it

Two new functions are added in worker.ts:

  • extractTenIdentifierFromPR(payload) — scans the PR's head.ref (branch name) and then title for the pattern /\bten[_-](\d+)\b/i and returns the canonical TEN-NNN string. Branch is checked first because it's more structured.
  • findTenIssueByIdentifier(ctx, companyId, identifier) — queries the issues API with the identifier as q, then filters for an exact identifier match (case-insensitive) so broad text-search tokenization can't produce false positives.

In onWebhook, after the primary findTenIssue full-text search returns null, the fallback fires: extract TEN identifier → look up by identifier → dispatch if found. The triage path is unchanged and still runs when the fallback also misses.

Technical summary

  • packages/plugins/examples/plugin-github-webhook-dispatcher/src/worker.ts
    • Added extractTenIdentifierFromPR (pure function, no async)
    • Added findTenIssueByIdentifier (async, one issues.list call)
    • Added fallback block in onWebhook between primary search and triage creation
  • tests/plugin.spec.ts
    • Added 3 new tests in PR branch/title fallback describe block

Verification

✓ tests/plugin.spec.ts (22 tests) 15ms
Test Files  1 passed (1)
     Tests  22 passed (22)

New tests:

  1. pull_request_review.submitted for a PR with branch ten-334-exact-match-issue-finder dispatches to TEN-334 (no ref in description)
  2. pull_request.opened with title fix(ten-334): … and non-matching branch dispatches to TEN-334
  3. PR with branch chore/update-deps and title chore: update deps (no TEN id) still creates triage issue

When an agent opens a PR without backfilling the GitHub ref into the
issue description, `findTenIssue`'s text search misses the parent issue
and creates a spurious triage issue instead of waking the assignee.

Add `extractTenIdentifierFromPR` to parse the PR's head branch name and
title for a TEN-NNN identifier (e.g. `ten-334-exact-match` or
`fix(ten-334): …`), and `findTenIssueByIdentifier` to look it up by
exact identifier match. The fallback is tried only when the primary
full-text search returns no result.

Three new tests cover: branch-based match for pull_request_review,
title-based match for pull_request.opened, and triage-issue creation
when neither branch nor title contains a TEN identifier.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@marvin-tensorleap marvin-tensorleap self-assigned this May 6, 2026
@lavie lavie merged commit 650b83e into ten-334-github-webhook-dispatcher May 6, 2026
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.

3 participants