jackwener/OpenCLI · info

Command returned an empty result.

Error message

Command returned an empty result.

What it means

The commander adapter warns when a command handler resolves to an empty result — either null/undefined or an empty array — while verbose output is enabled and no explicit format was chosen. The command still renders (empty table/output); this warning just tells the developer the site command produced no data.

Source

Thrown at src/commanderAdapter.ts:134

      const result = await executeCommand(cmd, kwargs, verbose, {
        prepared: true,
        ...(typeof globals.profile === 'string' && globals.profile.trim() ? { profile: globals.profile.trim() } : {}),
        ...(typeof optionsRecord.trace === 'string' && optionsRecord.trace !== 'off' ? { trace: optionsRecord.trace } : {}),
        ...(cmd.browser && typeof optionsRecord.window === 'string' ? { windowMode: optionsRecord.window } : {}),
        ...(cmd.browser && typeof optionsRecord.siteSession === 'string' ? { siteSession: optionsRecord.siteSession } : {}),
        ...(cmd.browser && typeof optionsRecord.keepTab === 'string' ? { keepTab: optionsRecord.keepTab } : {}),
      });
      if (result === null || result === undefined) {
        return;
      }

      const resolved = getRegistry().get(fullName(cmd)) ?? cmd;
      if (!formatExplicit && format === 'table' && resolved.defaultFormat) {
        format = resolved.defaultFormat;
      }

      if (verbose && (!result || (Array.isArray(result) && result.length === 0))) {
        log.warn('Command returned an empty result.');
      }
      renderOutput(result, {
        fmt: format,
        fmtExplicit: formatExplicit,
        columns: resolved.columns,
        title: `${resolved.site}/${resolved.name}`,
        elapsed: (Date.now() - startTime) / 1000,
        source: fullName(resolved),
        footerExtra: resolved.footerExtra?.(kwargs),
      });
    } catch (err) {
      renderError(err, fullName(cmd), optionsRecord.verbose === true, optionsRecord.trace);
      process.exitCode = resolveExitCode(err);
    }
  });
}

// ── Exit code resolution ─────────────────────────────────────────────────────

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check whether the result is legitimately empty (no matching rows on the site) — then the warning is expected.
  2. Loosen or remove filters/limits passed to the command and rerun.
  3. If results exist on the site but the CLI shows empty, inspect the site command handler for a missing return statement.
  4. Verify authentication/session state for that site; an auth-walled empty response can look like an empty result.

Example fix

// before
async function listItems() {
  const items = await fetchItems();
  // missing return -> empty result warning
}
// after
async function listItems() {
  const items = await fetchItems();
  return items;
}
Defensive patterns

Strategy: validation

Validate before calling

const result = await runCommand(args);
const empty = result == null || (Array.isArray(result) && result.length === 0);
if (empty) console.error('Command produced no data — check filters or auth before parsing output.');

Type guard

function hasRows<T>(r: T[] | null | undefined): r is T[] {
  return Array.isArray(r) && r.length > 0;
}

Prevention

When it happens

Trigger: Running any registered command with --verbose where the handler returned undefined/null or returned [] — e.g. a listing command whose site returned no rows.

Common situations: Querying a site/account that genuinely has no data; a filter that matches nothing; a handler bug that forgets to return its collected results; site-side empty pages.

Related errors


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