jackwener/OpenCLI · error · CommandExecutionError
Could not find ${formatLabel} citation link for result ${ind
Error message
Could not find ${formatLabel} citation link for result ${index + 1} What it means
After opening the Cite popup, the script scans the citation links for one whose text equals the requested format label (BibTeX, EndNote, RefMan, RefWorks); if none matches, it throws CommandExecutionError `Could not find ${formatLabel} citation link for result ${index+1}`. Unknown format values default to 'BibTeX' via formatMap, so this mainly fires when the popup did not contain the expected link.
Source
Thrown at clis/google-scholar/cite.js:58
if (!clicked?.ok) {
throw new CommandExecutionError(clicked?.reason || `Could not find search result at index ${index + 1}`);
}
await page.wait(2);
const formatMap = { bibtex: 'BibTeX', endnote: 'EndNote', refman: 'RefMan', refworks: 'RefWorks' };
const formatLabel = formatMap[format] || 'BibTeX';
const citeUrl = await page.evaluate(`(() => {
var links = document.querySelectorAll('#gs_cit a.gs_citi');
for (var i = 0; i < links.length; i++) {
if (links[i].textContent.trim() === '${formatLabel}') return links[i].href;
}
return null;
})()`);
if (!citeUrl) {
throw new CommandExecutionError(`Could not find ${formatLabel} citation link for result ${index + 1}`);
}
await page.goto(citeUrl);
await page.wait(2);
const citation = await page.evaluate(`(() => {
return (document.body.innerText || '').trim();
})()`);
if (!citation) {
throw new CommandExecutionError(`${formatLabel} citation page returned an empty response`);
}
return [{ title: clicked.title, format: format, citation }];
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Retry — popup load timing is often transient; add extra wait before citing
- Use the default 'bibtex' format, which is always present in the popup
- Slow down / solve any CAPTCHA if Scholar is throttling you
- Update the library if Scholar changed the cite popup markup
Example fix
// before
await scholarCite(page, 0, 'refworks'); // may not exist
// after
try { await scholarCite(page, 0, 'refworks'); }
catch (e) { if (/citation link/.test(e.message)) await scholarCite(page, 0, 'bibtex'); else throw e; } Defensive patterns
Strategy: fallback
Validate before calling
const supportedFormats = ['bibtex','endnote','refman','refworks']; if (!supportedFormats.includes(format)) format = 'bibtex';
Type guard
const isCiteFormat = (f) => ['bibtex','endnote','refman','refworks'].includes(f);
Try / catch
try { out = await scholarCite(page, i, fmt); }
catch (e) { if (/citation link/.test(e.message)) out = await scholarCite(page, i, 'bibtex'); else throw e; } Prevention
- Fall back to bibtex, which is always present in the cite popup
- Add extra wait after clicking Cite on slow connections
- Throttle request rate to avoid degraded Scholar responses
When it happens
Trigger: The cite popup failed to open or was empty for the chosen result; Google Scholar rendered a different popup layout; the popup's links hadn't loaded when evaluate ran (only a 2s wait precedes it).
Common situations: Requesting formats on result types lacking them; rate limiting producing a degraded popup; timing issues on slow connections where the 2s wait is insufficient.
Related errors
- Could not find search result at index ${index + 1}
- ${formatLabel} citation page returned an empty response
- settings click failed
- sidebar-toggle failed
- 无法在聊天列表中找到该用户,候选人可能不在当前列表中
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/7dfcaae3f36d986c.
Report an issue: GitHub.