{"record":{"id":"609040df665a829a","repo":"can1357/oh-my-pi","slug":"omp-auth-gateway-serve-requires-omp-auth-broker","errorCode":null,"errorMessage":"`omp auth-gateway serve` requires OMP_AUTH_BROKER_URL (or `auth.broker.url`/`auth.broker.token` in config.yml). The gateway is itself a broker client.","messagePattern":"`omp auth-gateway serve` requires OMP_AUTH_BROKER_URL \\(or `auth\\.broker\\.url`/`auth\\.broker\\.token` in config\\.yml\\)\\. The gateway is itself a broker client\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/auth-gateway-cli.ts","lineNumber":174,"sourceCode":" * credentials for, since only those are routable.\n */\nexport function indexModelsByRequestId(\n\tmodels: readonly Model<Api>[],\n\tprovidersWithCreds: ReadonlySet<string>,\n): Map<string, Model<Api>> {\n\tconst modelById = new Map<string, Model<Api>>();\n\tfor (const model of models) {\n\t\tif (!providersWithCreds.has(model.provider)) continue;\n\t\tmodelById.set(`${model.provider}/${model.id}`, model);\n\t\tif (!modelById.has(model.id)) modelById.set(model.id, model);\n\t}\n\treturn modelById;\n}\n\nasync function runServe(flags: AuthGatewayCommandArgs[\"flags\"]): Promise<void> {\n\tconst brokerConfig = await resolveAuthBrokerConfig();\n\tif (!brokerConfig) {\n\t\tthrow new Error(\n\t\t\t\"`omp auth-gateway serve` requires OMP_AUTH_BROKER_URL (or `auth.broker.url`/`auth.broker.token` in config.yml). The gateway is itself a broker client.\",\n\t\t);\n\t}\n\tconst bind = flags.bind ?? DEFAULT_AUTH_GATEWAY_BIND;\n\tconst gatewayToken = flags.noAuth ? null : await ensureToken();\n\n\t// Build a broker-backed AuthStorage — same pattern as discoverAuthStorage()\n\t// in sdk.ts. The gateway never touches local SQLite.\n\tconst accountPool = await loadAuthBrokerAccountPool();\n\tconst client = createBrokerClient(brokerConfig);\n\tconst initialSnapshot = await fetchBrokerSnapshot(client);\n\tconst store = new RemoteAuthCredentialStore({\n\t\tclient,\n\t\tinitialSnapshot,\n\t\taccountPool,\n\t});\n\t// Refresh + usage both flow through the store's broker hooks automatically —\n\t// `RemoteAuthCredentialStore.refreshOAuthCredential` and `.fetchUsageReports`.","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/auth-gateway-cli.ts#L156-L192","documentation":"`omp auth-gateway serve` proxies broker credentials, so it must itself be configured as a broker client. runServe throws when resolveAuthBrokerConfig() returns null — i.e. neither OMP_AUTH_BROKER_URL nor auth.broker.url/auth.broker.token in config.yml provide broker connection details. This is a fail-fast configuration validation before binding the server.","triggerScenarios":"Running `omp auth-gateway serve` in an environment with no OMP_AUTH_BROKER_URL env var and no auth.broker.url/auth.broker.token keys in config.yml.","commonSituations":"CI/containers where env vars weren't propagated; fresh checkout without config.yml; running serve on a machine distinct from the one with broker config; typo'd env var name.","solutions":["Export OMP_AUTH_BROKER_URL (and token if required) before running the command.","Add auth.broker.url and auth.broker.token to config.yml.","Run the command from an environment that loads your dotenv/profile where the broker vars are set."],"exampleFix":"// before (shell)\nomp auth-gateway serve\n// after (shell)\nOMP_AUTH_BROKER_URL=https://broker.example.com OMP_AUTH_BROKER_TOKEN=... omp auth-gateway serve","handlingStrategy":"validation","validationCode":"if (!process.env.OMP_AUTH_BROKER_URL) {\n  const cfg = await readConfig();\n  if (!cfg.auth?.broker?.url) process.exit(1);\n}","typeGuard":"function hasBrokerConfig(c: unknown): c is { url: string; token?: string } {\n  return typeof (c as { url?: unknown })?.url === \"string\";\n}","tryCatchPattern":"try {\n  await $`omp auth-gateway serve`.quiet().nothrow();\n} catch (err) {\n  if (String(err).includes(\"requires OMP_AUTH_BROKER_URL\")) {\n    console.error(\"Set OMP_AUTH_BROKER_URL or auth.broker.url in config.yml\");\n  }\n}","preventionTips":["Set OMP_AUTH_BROKER_URL in the deployment env/entrypoint","Keep auth.broker.url/token in config.yml for non-CI environments","Document required env vars in your run scripts"],"tags":["auth-gateway","configuration","missing-env-var"],"backgroundTag":"missing-env-var","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}