{"record":{"id":"6b6f7d3cc602eae0","repo":"tinyhumansai/openhuman","slug":"openai-codex-oauth-missing-auth-url","errorCode":"OPENAI_CODEX_OAUTH_MISSING_AUTH_URL","errorMessage":"OPENAI_CODEX_OAUTH_MISSING_AUTH_URL","messagePattern":"OPENAI_CODEX_OAUTH_MISSING_AUTH_URL","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/services/api/aiSettingsApi.ts","lineNumber":726,"sourceCode":"\n/** Clear a stored API key. */\nexport async function clearCloudProviderKey(slug: string): Promise<void> {\n  if (slug === 'openhuman') {\n    return;\n  }\n  // Clear the new-style key. Legacy bare-slug entries are left as-is\n  // since we can't be sure they aren't used by other things.\n  await authRemoveProviderCredentials({ provider: authKeyForSlug(slug), profile: 'default' });\n}\n\nexport async function startOpenAiCodexOAuth(): Promise<OpenAiCodexOAuthStartResult> {\n  const res = await callCoreRpc<{ result: OpenAiCodexOAuthStartResult }>({\n    method: 'openhuman.inference_openai_oauth_start',\n    params: {},\n  });\n  const authUrl = res?.result?.authUrl?.trim();\n  if (!authUrl) {\n    throw new Error(OPENAI_CODEX_OAUTH_MISSING_AUTH_URL);\n  }\n  return res.result;\n}\n\nexport async function completeOpenAiCodexOAuth(callbackUrl: string): Promise<void> {\n  const callback = callbackUrl.trim();\n  if (!callback) {\n    throw new Error(OPENAI_CODEX_OAUTH_MISSING_CALLBACK_URL);\n  }\n  await callCoreRpc({\n    method: 'openhuman.inference_openai_oauth_complete',\n    params: { callback_url: callback },\n  });\n}\n\nexport async function importOpenAiCodexCliAuth(): Promise<void> {\n  await callCoreRpc({ method: 'openhuman.inference_openai_oauth_import_codex_cli', params: {} });\n}","sourceCodeStart":708,"sourceCodeEnd":744,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/app/src/services/api/aiSettingsApi.ts#L708-L744","documentation":"startOpenAiCodexOAuth called the core RPC openhuman.inference_openai_oauth_start successfully, but the result carried no non-empty result.authUrl (after trim). Without an authorization URL there is nothing to open in a browser, so the OAuth flow cannot start; the constant OPENAI_CODEX_OAUTH_MISSING_AUTH_URL marks this specific failure.","triggerScenarios":"Invoking 'Sign in with ChatGPT/Codex' and the core's OpenAI OAuth start handler returns { result: {} } or { result: { authUrl: '  ' } } — e.g. missing/misconfigured OAuth client credentials on the core side, or a core build where the OpenAI OAuth feature is degraded.","commonSituations":"Dev environment without the required OpenAI OAuth client id/secret configured in the core; version skew between an older core and a newer frontend expecting authUrl; enterprise proxy stripping the field. The RPC 'succeeds', so the failure only appears at this shape check.","solutions":["Update/restart the desktop core so inference_openai_oauth_start runs the current implementation","Check the core-side OpenAI OAuth configuration (client id/secret env or config) and complete it","Inspect the core logs for the oauth start handler to see why authUrl was omitted","Wrap the call and surface a clear 'could not start OpenAI sign-in' message with a retry"],"exampleFix":"// before\nconst { authUrl } = await startOpenAiCodexOAuth();\nwindow.open(authUrl, '_blank');\n\n// after\nlet authUrl: string;\ntry {\n  ({ authUrl } = await startOpenAiCodexOAuth());\n} catch (e) {\n  showOAuthError('Could not start OpenAI sign-in. Update the app and try again.');\n  return;\n}\nwindow.open(authUrl, '_blank');","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const hasAuthUrl = (r: unknown): r is { authUrl: string } =>\n  typeof (r as { authUrl?: unknown })?.authUrl === 'string' && (r as { authUrl: string }).authUrl.trim().length > 0;","tryCatchPattern":"try { const { authUrl } = await startOpenAiCodexOAuth(); openInBrowser(authUrl); }\ncatch (e) { showOAuthError('Could not start OpenAI sign-in — update/restart the app and retry.'); logError(e); }","preventionTips":["Treat OAuth start as fallible UI flow with explicit error state and retry","Keep core and frontend versions in sync after OAuth-related updates","Log the raw RPC result when authUrl is missing to speed up core-side diagnosis"],"tags":["oauth","ai-settings","response-shape","openai-codex"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}