jackwener/OpenCLI · info · EmptyResultError
${label}
Error message
${label} What it means
requireNonEmptyRows delegates to EmptyResultError(label, hint): the query executed successfully but returned zero rows. This is a signal, not a failure — the CLI surfaces it distinctly (with a hint) so scripts can tell 'no matches' apart from 'bad query'.
Source
Thrown at clis/_atlassian/shared.js:270
export function requirePayloadArray(value, label) {
if (!Array.isArray(value)) {
throw new CommandExecutionError(`${label} returned an unexpected payload shape; expected an array.`);
}
return value;
}
export function requirePayloadString(value, field, label) {
if (typeof value !== 'string' && typeof value !== 'number') {
throw new CommandExecutionError(`${label} did not include a stable ${field}.`);
}
const s = String(value).trim();
if (!s) throw new CommandExecutionError(`${label} did not include a stable ${field}.`);
return s;
}
export function requireNonEmptyRows(rows, label, hint) {
if (!rows.length) throw new EmptyResultError(label, hint);
return rows;
}
export function parseLimit(value, defaultValue = 20, maxValue = 100, label = 'limit') {
const raw = value ?? defaultValue;
const n = typeof raw === 'number' ? raw : Number(raw);
if (!Number.isInteger(n) || n <= 0) {
throw new ArgumentError(`${label} must be a positive integer`);
}
if (n > maxValue) {
throw new ArgumentError(`${label} must be <= ${maxValue}`);
}
return n;
}
export function requireExecute(args, commandName) {
if (args.execute !== true) {
throw new ArgumentError(`${commandName} requires --execute to perform a remote write`);View on GitHub (pinned to 49907e53dc)
Solutions
- Relax or correct the query (CQL/JQL) — verify space keys, labels, and date ranges.
- Confirm the content exists and isn't in trash/archived.
- Check permissions: the API user may not see the matching pages/issues.
- Handle EmptyResultError in scripts so empty results don't crash pipelines.
Example fix
# before (overly restrictive query) opencli confluence search --cql 'label = "q3-okr" AND space = DEV' # after — verify stepwise opencli confluence search --cql 'space = DEV' # then add filters
Defensive patterns
Strategy: try-catch
Validate before calling
// sanity-check the query before running
if (!cql || !cql.trim()) throw new Error('CQL query is empty');
const spaceKey = 'DEV';
if (spaceKey.length < 2) console.warn('Space key looks too short — verify it'); Try / catch
try {
const rows = await searchCmd(args);
} catch (e) {
if (e instanceof EmptyResultError || /no results/i.test(e.message)) {
console.warn('No matching content — relaxing query or checking permissions.');
return [];
}
throw e;
} Prevention
- Test CQL/JQL queries in the web UI before scripting them.
- Confirm space keys, labels, and permissions for the API user.
- Remember trash/archived content is excluded from search.
- Treat empty results as data, not errors, in pipelines.
When it happens
Trigger: A search whose CQL/JQL matches nothing; listing pages in an empty space; filtering by a label/macro that no content uses; permissions hiding all matching content from the authenticated user.
Common situations: Typo'd space key or label; searching the wrong site/instance; content archived or in trash so it's excluded from results; restricted pages invisible to the API token's user.
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 Indeed jobs matched "${query}"${location ? ` in ${locatio
- 未找到匹配 "${query}" 的候选人
- npm search
- pubmed journal
- No 12306 stations match "${keyword}"
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/ccac27cfbb3f86b6.
Report an issue: GitHub.