{"record":{"id":"25955d29b9c2ca19","repo":"google-gemini/gemini-cli","slug":"command-command-returned-empty-output","errorCode":null,"errorMessage":"Command '${command}' returned empty output","messagePattern":"Command '(.+?)' returned empty output","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/agents/auth-provider/value-resolver.ts","lineNumber":69,"sourceCode":"      throw new Error('Empty command in auth value. Expected format: !command');\n    }\n\n    debugLogger.debug(`[AuthValueResolver] Executing command for auth value`);\n\n    const shellConfig = getShellConfiguration();\n    try {\n      const { stdout } = await spawnAsync(\n        shellConfig.executable,\n        [...shellConfig.argsPrefix, command],\n        {\n          signal: AbortSignal.timeout(COMMAND_TIMEOUT_MS),\n          windowsHide: true,\n        },\n      );\n\n      const trimmed = stdout.trim();\n      if (!trimmed) {\n        throw new Error(`Command '${command}' returned empty output`);\n      }\n      return trimmed;\n    } catch (error) {\n      if (error instanceof Error && error.name === 'AbortError') {\n        throw new Error(\n          `Command '${command}' timed out after ${COMMAND_TIMEOUT_MS / 1000} seconds`,\n        );\n      }\n      throw error;\n    }\n  }\n\n  // Literal value - return as-is\n  return value;\n}\n\n/**\n * Check if a value needs resolution (is an env var or command reference).","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/core/src/agents/auth-provider/value-resolver.ts#L51-L87","documentation":"Thrown by resolveAuthValue after a shell command (the ! sigil) executed and exited successfully but stdout was empty or whitespace-only after trimming. The command ran without throwing, so this is an output-content failure, not a process failure.","triggerScenarios":"resolveAuthValue('!some-command') where some-command exits 0 and prints nothing to stdout (or only whitespace). Typical with credential helpers that silently produce no output when unauthenticated.","commonSituations":"Credential helper not logged in (e.g. '!gcloud auth print-access-token' before `gcloud auth login`; '!op get item ...' when 1Password CLI session expired); command writes the secret to stderr instead of stdout; command needs arguments that were omitted; command echoes to a file rather than stdout; region/account context not set so the helper yields empty.","solutions":["Run the command manually in the same shell/environment and confirm it prints the secret to stdout.","Re-authenticate the credential helper (e.g. gcloud auth login, op signin).","If the secret is on stderr, wrap the command to redirect: '!gcloud ... 2>&1' or rewrite to stdout.","Verify any required args / context flags are present in the command string.","Prefer reading from an env var ($VAR) if the command is flaky."],"exampleFix":"# before\naccessToken: '!gcloud auth print-access-token'   # empty when logged out\n\n# after: ensure stdout output and auth state\ngcloud auth login\naccessToken: '!gcloud auth print-access-token'","handlingStrategy":"validation","validationCode":"// Pre-flight: run the command and assert non-empty stdout before relying on it.\nimport { spawnSync } from 'node:child_process';\nfunction preflightCmd(cmd) {\n  const { stdout } = spawnSync(cmd, { shell: true });\n  if (!stdout.toString().trim())\n    throw new Error(`Auth command produced no output: ${cmd}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const val = await resolveAuthValue('!gcloud auth print-access-token');\n} catch (e) {\n  if (e instanceof Error && /returned empty output/.test(e.message)) {\n    // run `gcloud auth login` then retry\n  }\n  throw e;\n}","preventionTips":["Run each !-command manually once to confirm stdout output.","Ensure the credential helper is authenticated before the agent starts.","Redirect stderr to stdout if the helper writes the secret to stderr."],"tags":["auth","shell","config"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}