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

  1. Relax or correct the query (CQL/JQL) — verify space keys, labels, and date ranges.
  2. Confirm the content exists and isn't in trash/archived.
  3. Check permissions: the API user may not see the matching pages/issues.
  4. 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

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/ccac27cfbb3f86b6. Report an issue: GitHub.