{"record":{"id":"d04965071c057989","repo":"can1357/oh-my-pi","slug":"unknown-auth-gateway-action-string-exhaustive","errorCode":null,"errorMessage":"Unknown auth-gateway action: ${String(_exhaustive)}","messagePattern":"Unknown auth-gateway action: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/auth-gateway-cli.ts","lineNumber":405,"sourceCode":"}\n\nexport async function runAuthGatewayCommand(cmd: AuthGatewayCommandArgs): Promise<void> {\n\tswitch (cmd.action) {\n\t\tcase \"serve\":\n\t\t\tawait runServe(cmd.flags);\n\t\t\treturn;\n\t\tcase \"token\":\n\t\t\tawait runToken(cmd.flags);\n\t\t\treturn;\n\t\tcase \"status\":\n\t\t\tawait runStatus(cmd.flags);\n\t\t\treturn;\n\t\tcase \"check\":\n\t\t\tawait runCheck(cmd.flags);\n\t\t\treturn;\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = cmd.action;\n\t\t\tthrow new Error(`Unknown auth-gateway action: ${String(_exhaustive)}`);\n\t\t}\n\t}\n}\n\n/**\n * Providers whose chat endpoint expects a JSON-serialized credential blob\n * (`{ token, projectId, refreshToken, expiresAt, … }`) rather than the raw\n * access token. Mirrors `getOAuthApiKey` in `packages/ai/src/registry/oauth`.\n */\nconst STRUCTURED_API_KEY_PROVIDERS: ReadonlySet<string> = new Set([\n\t\"github-copilot\",\n\t\"google-gemini-cli\",\n\t\"google-antigravity\",\n]);\n\n/**\n * Provider API types that strict-mode chat probes intentionally skip:\n * - `bedrock-converse-stream` resolves credentials from the AWS env/profile, not the broker bearer.","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/auth-gateway-cli.ts#L387-L423","documentation":"runAuthGatewayCommand switches over the gateway's action union; the default branch is an exhaustiveness assertion (`const _exhaustive: never = cmd.action`) that throws at runtime if an action reaches dispatch without a handled case. Like error 901, it protects against internal CLI wiring bugs, not normal user input.","triggerScenarios":"A new auth-gateway action is added to the parser/union but the switch in runAuthGatewayCommand lacks a matching case; inconsistent builds.","commonSituations":"Contributor adds a `serve`-like new subcommand and forgets the case; partially applied patches or stale compiled output.","solutions":["Add the missing `case \"<action>\"` branch to runAuthGatewayCommand.","Rebuild/reinstall so the command parser and dispatcher match.","Report as a bug if it occurs without local code changes."],"exampleFix":"// before\ncase \"check\":\n  await runCheck(cmd.flags);\n  return;\ndefault: { ... }\n// after\ncase \"check\":\n  await runCheck(cmd.flags);\n  return;\ncase \"token\":\n  await runToken(cmd.flags);\n  return;\ndefault: { ... }","handlingStrategy":"type-guard","validationCode":"const GATEWAY_ACTIONS = [\"serve\",\"check\",\"token\"] as const;\nif (!GATEWAY_ACTIONS.includes(action)) usage(1);","typeGuard":"function isGatewayAction(a: unknown): a is AuthGatewayAction {\n  return typeof a === \"string\" && GATEWAY_ACTIONS.includes(a as AuthGatewayAction);\n}","tryCatchPattern":"try {\n  await runAuthGatewayCommand(cmd);\n} catch (err) {\n  if (String(err).startsWith(\"Unknown auth-gateway action\")) {\n    console.error(`Unknown action; see omp auth-gateway --help`);\n  }\n  throw err;\n}","preventionTips":["Add a switch case whenever the action union grows","Keep the parser and dispatcher in one module to avoid drift","Run bun check to let the never-check catch gaps at compile time"],"tags":["typescript","exhaustiveness","cli"],"backgroundTag":"unhandled-enum-case","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}