[object Object]

← back to Rentv

pr/search: Cody gate — (1) strip internal double-quotes in term() so a name like The "Best" Group can't corrupt the phrase query; (2) short-circuit a degenerate bare 'site:linkedin.com/in|company' query (person+company both empty, reachable via locateCompany w/ null org) to an empty DEGENERATE_QUERY report — don't burn a paid search API call on a random LinkedIn sampling. Verified

685e6ac40dee4c3484d33cf70f4464a59387eb84 · 2026-08-05 21:26:25 -0700 · Steve

Files touched

Diff

commit 685e6ac40dee4c3484d33cf70f4464a59387eb84
Author: Steve <steve@designerwallcoverings.com>
Date:   Wed Aug 5 21:26:25 2026 -0700

    pr/search: Cody gate — (1) strip internal double-quotes in term() so a name like The "Best" Group can't corrupt the phrase query; (2) short-circuit a degenerate bare 'site:linkedin.com/in|company' query (person+company both empty, reachable via locateCompany w/ null org) to an empty DEGENERATE_QUERY report — don't burn a paid search API call on a random LinkedIn sampling. Verified
---
 src/pr/adapters/search.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/pr/adapters/search.js b/src/pr/adapters/search.js
index adfd7c1f..30c684bb 100644
--- a/src/pr/adapters/search.js
+++ b/src/pr/adapters/search.js
@@ -94,11 +94,16 @@ const adapter = register({
     // Build from NON-EMPTY quoted terms only. A null/undefined/'' company (a person with no org, e.g.
     // jobs/index.js passes p.org_name) must NOT inject a literal "null"/"undefined"/empty "" phrase
     // into the query — that constrains the search to garbage and tanks the LinkedIn match rate.
-    const term = (v) => (v && String(v).trim()) ? `"${String(v).trim()}"` : null;
+    const term = (v) => (v && String(v).trim()) ? `"${String(v).trim().replace(/"/g, '')}"` : null; // strip internal quotes so a name like The "Best" Group can't corrupt the phrase query
     const parts = kind === 'company'
       ? ['site:linkedin.com/company', term(companyName)]
       : ['site:linkedin.com/in', term(personName), term(companyName)];
     const q = parts.filter(Boolean).join(' ');
+    // No searchable terms (person + company both empty) → a bare `site:` operator returns a random
+    // sampling of LinkedIn, not a match. Short-circuit so we don't burn a paid API call on garbage.
+    if (!/"/.test(q)) {
+      return report({ provider: 'search', query: q, errors: [{ error: 'no search terms (personName and companyName both empty)', code: 'DEGENERATE_QUERY' }], confidence_recommendation: 0, items: [] });
+    }
     const rep = await adapter.search(q, { numResults: 5 });
     rep.items = rep.items.filter((x) => /linkedin\.com\/(in|company)\//i.test(x.url));
     rep.result_count = rep.items.length;

← 4cc523f8 pr/search: fix findLinkedIn query building — a null/undefine  ·  back to Rentv  ·  auto-save: 2026-08-05T21:46:07 (7 files) — data/deals-regist 430a62a6 →