From 05f7e2ac405f5506b74ed6b0c824d7c69e9811f2 Mon Sep 17 00:00:00 2001 From: ConciergeLead Date: Wed, 6 May 2026 11:53:52 +0000 Subject: [PATCH] fix(ten-334): exact-match GitHub ref in issue search, remove result cap Text search tokenizes the query (e.g. "tensorleap/concierge#413") and can return false-positive matches. Replace the first-result heuristic with an exact-string filter: fetch all candidates (no limit), then accept only issues whose title or description literally contains the full ref. Co-Authored-By: Paperclip --- .../src/worker.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/plugins/examples/plugin-github-webhook-dispatcher/src/worker.ts b/packages/plugins/examples/plugin-github-webhook-dispatcher/src/worker.ts index 651ed5ce690..48ff995d890 100644 --- a/packages/plugins/examples/plugin-github-webhook-dispatcher/src/worker.ts +++ b/packages/plugins/examples/plugin-github-webhook-dispatcher/src/worker.ts @@ -219,11 +219,19 @@ async function findTenIssue( companyId: string, githubRef: string, ): Promise<{ id: string; identifier: string } | null> { - const results = await ctx.issues.list({ companyId, q: githubRef, limit: 5 }); + // No limit: text search may tokenize the query and return many broad matches; + // we need all candidates so the exact-string filter below can find the right one. + const results = await ctx.issues.list({ companyId, q: githubRef }); if (!results || results.length === 0) return null; - const issue = results[0]; - if (!issue) return null; - return { id: issue.id, identifier: issue.identifier ?? issue.id }; + // Only accept issues where the ref literally appears in title or description. + const needle = githubRef.toLowerCase(); + const exact = results.find( + (issue) => + (issue.title?.toLowerCase().includes(needle) ?? false) || + (issue.description?.toLowerCase().includes(needle) ?? false), + ); + if (!exact) return null; + return { id: exact.id, identifier: exact.identifier ?? exact.id }; } // ──────────────────────────────────────────────