jackwener/OpenCLI · warning · EmptyResultError
linkedin salesnav-search
Error message
linkedin salesnav-search
What it means
An EmptyResultError raised in clis/linkedin/salesnav-search.js:168 when the pagination loop completed and deduplicated leads but collected zero results. The command treats an empty result set as an exceptional outcome so callers and pipeline steps can detect 'nothing matched' distinctly from malformed responses. The first argument is the command name and the second is the human-readable explanation.
Source
Thrown at clis/linkedin/salesnav-search.js:168
const leads = [];
const seen = new Set();
for (let start = 0; leads.length < limit && start < 2000; start += PAGE_SIZE) {
const result = unwrapEvaluateResult(await page.evaluate(fetchLeadSearchScript(leadSearchUrl(keywords, start), csrf)));
const json = requireLeadSearchResult(result);
const pageLeads = parseLeads(json);
if (pageLeads.length === 0) break;
for (const lead of pageLeads) {
const key = lead.profile_url || lead.name.toLowerCase();
if (seen.has(key)) continue;
seen.add(key);
leads.push(lead);
}
await page.wait(1);
}
if (leads.length === 0) {
throw new EmptyResultError('linkedin salesnav-search', 'No Sales Navigator leads were found.');
}
return leads.slice(0, limit).map((lead, index) => ({ rank: index + 1, ...lead }));
},
});
export const __test__ = {
normalizeWhitespace,
parseLimit,
leadSearchUrl,
profileUrlFromEntityUrn,
leadUrlFromEntityUrn,
parseLeads,
requireLeadSearchResult,
};
View on GitHub (pinned to 49907e53dc)
Solutions
- Broaden the keywords (fewer, more generic terms) and re-run, e.g. 'quality manager food' instead of an exact long phrase.
- Confirm the account actually has Sales Navigator access and can see results by running the same search in the Sales Navigator UI.
- Wrap the call in a try/catch for EmptyResultError when zero results is an acceptable outcome in your pipeline.
- Try the query with alternate spellings or via LinkedIn people search if the target population is very small.
Example fix
// before (crash pipeline on empty)
const leads = await run('linkedin salesnav-search', ['quality manager food manufacturing']);
// after (tolerate empty)
try {
const leads = await run('linkedin salesnav-search', ['quality manager food manufacturing']);
} catch (err) {
if (err.name === 'EmptyResultError') return [];
throw err;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Sanity-check keywords before the search:
const kw = String(keywords || '').trim();
if (kw.length < 3) throw new Error('keywords too narrow/short for a meaningful Sales Navigator search'); Try / catch
try {
const leads = await run('linkedin salesnav-search', [keywords, '--limit', '50']);
} catch (err) {
if (err.name === 'EmptyResultError') {
console.warn(`No leads for "${keywords}"; broadening query.`);
return run('linkedin salesnav-search', [keywords.split(/\s+/).slice(0, 2).join(' ')]);
}
throw err;
} Prevention
- Start with broad keywords and narrow iteratively; long exact phrases often match nothing.
- Confirm the signed-in seat can see the target population in the Sales Navigator UI before automating.
- Treat EmptyResultError as data (catch and return []) when zero hits is a valid business outcome.
When it happens
Trigger: The keyword query matches no Sales Navigator leads; every paginated parseLeads(json) call returned an empty elements array so the loop broke immediately; search results exist but all rows fail entityUrn/name validation and are never pushed (parseLeads would throw first, so practically this is a genuine empty response).
Common situations: Overly narrow keyword strings with typos; searching for people outside the account's Sales Navigator visibility (network/degree filters); region-restricted searches returning zero for the signed-in seat; keywords targeting a company with no Sales Navigator-indexed employees.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- No LinkedIn Learning results for "${keywords}"
- No Sales Navigator thread matched ${input}
- No messages found for ${threadId}
- No 12306 stations match "${keyword}"
- ${label}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/09f3c3f28087bbd8.
Report an issue: GitHub.