jackwener/OpenCLI · info · EmptyResultError
No MDN results matched "${query}" (locale ${locale}).
Error message
No MDN results matched "${query}" (locale ${locale}). What it means
EmptyResultError thrown when the MDN search API responds successfully but returns zero documents for the query and locale. This is a signal that nothing matched, not a malfunction — the message includes the query and locale for clarity.
Source
Thrown at clis/mdn/search.js:86
if (resp.status === 429) {
throw new CommandExecutionError(
'mdn search returned HTTP 429 (rate limited)',
'MDN throttles bursty traffic; wait a few seconds and retry.',
);
}
if (!resp.ok) {
throw new CommandExecutionError(`mdn search returned HTTP ${resp.status}`);
}
let body;
try {
body = await resp.json();
}
catch (err) {
throw new CommandExecutionError(`mdn search returned malformed JSON: ${err?.message ?? err}`);
}
const docs = Array.isArray(body?.documents) ? body.documents : [];
if (!docs.length) {
throw new EmptyResultError('mdn search', `No MDN results matched "${query}" (locale ${locale}).`);
}
return docs.slice(0, limit).map((doc, i) => ({
rank: i + 1,
title: String(doc.title ?? ''),
slug: String(doc.slug ?? ''),
locale: String(doc.locale ?? locale),
summary: String(doc.summary ?? '').replace(/\s+/g, ' ').trim(),
url: doc.mdn_url ? `${MDN_BASE}${doc.mdn_url}` : '',
}));
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Rephrase or shorten the query (e.g. 'array reduce' instead of a full sentence).
- Retry with locale 'en-US', which has the most complete coverage.
- Check spelling of the API/feature name.
- Try related or broader terms (e.g. 'map' instead of 'typed array map constructor').
Example fix
// before
await mdnSearch({ query: 'querySelectorr All', locale: 'ja' });
// after
try {
return await mdnSearch({ query: 'querySelectorAll', locale: 'ja' });
} catch (e) {
if (String(e.message).includes('No MDN results')) {
return await mdnSearch({ query: 'querySelectorAll', locale: 'en-US' });
}
throw e;
} Defensive patterns
Strategy: fallback
Validate before calling
if (!query || !query.trim()) return []; // avoid pointless no-match requests
Try / catch
try { return await mdnSearch({ query, locale }); } catch (e) {
if (String(e.message).includes('No MDN results')) return suggestAlternatives(query);
throw e;
} Prevention
- Normalize/spellcheck queries before searching
- Fall back to en-US when localized results are empty
- Offer related-term suggestions on empty results
- Prefer shorter, keyword-style queries
When it happens
Trigger: Searching a term MDN has no page for; misspelled API/class names; searching in a locale where the article does not exist (docs array is empty for that locale).
Common situations: Typos in API names ('queryselector al'); obscure or very new features not yet documented; non-en-US locales with missing translations; overly specific multi-word queries.
Related errors
- No 12306 stations match "${keyword}"
- ${label}
- No papers found for author "${authorText}". Try alternate sp
- No papers found. Try a different keyword.
- crates search
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/bcae53bf4800474e.
Report an issue: GitHub.