jackwener/OpenCLI · warning · EmptyResultError
oeis search
oeis search
Error message
No OEIS sequences matched "${query}". What it means
An EmptyResultError with code "oeis search" thrown when a paginated OEIS search collected zero results for the query. The OEIS API answered successfully but no sequences matched the search terms. The library raises this instead of returning an empty array so callers get an explicit signal.
Source
Thrown at clis/oeis/search.js:47
const collected = [];
let start = 0;
const pageSize = 10;
// Cap iterations defensively at limit/pageSize + 1 so we never spin forever.
const maxPages = Math.ceil(limit / pageSize) + 1;
for (let page = 0; page < maxPages && collected.length < limit; page++) {
const url = `${OEIS_BASE}/search?q=${encodeURIComponent(query)}&fmt=json&start=${start}`;
const body = await oeisFetch(url, 'oeis search');
const list = Array.isArray(body) ? body : [];
if (!list.length) break;
for (const r of list) {
if (collected.length >= limit) break;
collected.push(r);
}
if (list.length < pageSize) break;
start += pageSize;
}
if (!collected.length) {
throw new EmptyResultError('oeis search', `No OEIS sequences matched "${query}".`);
}
return collected.map((r, i) => {
const id = formatId(r?.number);
return {
rank: i + 1,
id,
name: typeof r?.name === 'string' ? r.name : null,
keywords: typeof r?.keyword === 'string' ? r.keyword : null,
preview: previewTerms(r?.data),
author: typeof r?.author === 'string' ? r.author : null,
created: typeof r?.created === 'string' ? r.created : null,
url: id ? `${OEIS_BASE}/${id}` : '',
};
});
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Simplify the query to just the numeric terms, e.g. "1,2,4,8,16".
- Check spelling/typos in number sequences and keywords.
- Try fewer terms — dropping the least important term widens the match.
- Use OEIS's own web search to confirm results exist before scripting.
Example fix
// before oeis search "primes ending in 7 discovered by Gauss" // after oeis search "7,37,67,97"
Defensive patterns
Strategy: try-catch
Validate before calling
// require a non-empty query with at least one term
const q = String(raw ?? '').trim();
if (!q) throw new Error('query required'); Type guard
const hasQuery = (v) => typeof v === 'string' && v.trim().length > 0;
Try / catch
try { return await oeisSearch(q); } catch (e) { if (e.code === 'oeis search') return suggestQueryBroadening(q); throw e; } Prevention
- Search plain comma-separated number terms, not prose.
- Validate queries non-empty before invoking.
- Test the query on oeis.org interactively first.
- Programmatically relax the query (drop terms) and retry once on empty results.
When it happens
Trigger: Calling the oeis search command with a query string that matches nothing: misspelled sequence terms, overly restrictive/long queries, or a query mixing too many numbers that no single sequence contains.
Common situations: Searching natural-language descriptions OEIS doesn't index, entering terms in the wrong order, searching for a typo'd number sequence, or querying keywords too specific (author names, dates).
Related errors
- oeis sequence
- No 12306 stations match "${keyword}"
- ${label}
- No papers found for author "${authorText}". Try alternate sp
- No papers found. Try a different keyword.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/df7a26ffb8673d9d.
Report an issue: GitHub.