{"record":{"id":"de121fd25b724914","repo":"jackwener/OpenCLI","slug":"command-returned-an-empty-result","errorCode":null,"errorMessage":"Command returned an empty result.","messagePattern":"Command returned an empty result\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/commanderAdapter.ts","lineNumber":134,"sourceCode":"      const result = await executeCommand(cmd, kwargs, verbose, {\n        prepared: true,\n        ...(typeof globals.profile === 'string' && globals.profile.trim() ? { profile: globals.profile.trim() } : {}),\n        ...(typeof optionsRecord.trace === 'string' && optionsRecord.trace !== 'off' ? { trace: optionsRecord.trace } : {}),\n        ...(cmd.browser && typeof optionsRecord.window === 'string' ? { windowMode: optionsRecord.window } : {}),\n        ...(cmd.browser && typeof optionsRecord.siteSession === 'string' ? { siteSession: optionsRecord.siteSession } : {}),\n        ...(cmd.browser && typeof optionsRecord.keepTab === 'string' ? { keepTab: optionsRecord.keepTab } : {}),\n      });\n      if (result === null || result === undefined) {\n        return;\n      }\n\n      const resolved = getRegistry().get(fullName(cmd)) ?? cmd;\n      if (!formatExplicit && format === 'table' && resolved.defaultFormat) {\n        format = resolved.defaultFormat;\n      }\n\n      if (verbose && (!result || (Array.isArray(result) && result.length === 0))) {\n        log.warn('Command returned an empty result.');\n      }\n      renderOutput(result, {\n        fmt: format,\n        fmtExplicit: formatExplicit,\n        columns: resolved.columns,\n        title: `${resolved.site}/${resolved.name}`,\n        elapsed: (Date.now() - startTime) / 1000,\n        source: fullName(resolved),\n        footerExtra: resolved.footerExtra?.(kwargs),\n      });\n    } catch (err) {\n      renderError(err, fullName(cmd), optionsRecord.verbose === true, optionsRecord.trace);\n      process.exitCode = resolveExitCode(err);\n    }\n  });\n}\n\n// ── Exit code resolution ─────────────────────────────────────────────────────","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/src/commanderAdapter.ts#L116-L152","documentation":"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.","triggerScenarios":"Running any registered command with --verbose where the handler returned undefined/null or returned [] — e.g. a listing command whose site returned no rows.","commonSituations":"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.","solutions":["Check whether the result is legitimately empty (no matching rows on the site) — then the warning is expected.","Loosen or remove filters/limits passed to the command and rerun.","If results exist on the site but the CLI shows empty, inspect the site command handler for a missing return statement.","Verify authentication/session state for that site; an auth-walled empty response can look like an empty result."],"exampleFix":"// before\nasync function listItems() {\n  const items = await fetchItems();\n  // missing return -> empty result warning\n}\n// after\nasync function listItems() {\n  const items = await fetchItems();\n  return items;\n}","handlingStrategy":"validation","validationCode":"const result = await runCommand(args);\nconst empty = result == null || (Array.isArray(result) && result.length === 0);\nif (empty) console.error('Command produced no data — check filters or auth before parsing output.');","typeGuard":"function hasRows<T>(r: T[] | null | undefined): r is T[] {\n  return Array.isArray(r) && r.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Confirm the site actually has data before debugging empty results.","Always return collected results from command handlers.","Run with --verbose to surface the empty-result warning during development."],"tags":["cli","empty-result","output"],"backgroundTag":"empty-command-result","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}