{"record":{"id":"d54d4107b09fa569","repo":"earendil-works/pi","slug":"openai-codex-oauth-is-only-available-in-node-js-en","errorCode":null,"errorMessage":"OpenAI Codex OAuth is only available in Node.js environments","messagePattern":"OpenAI Codex OAuth is only available in Node\\.js environments","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ai/src/auth/oauth/openai-codex.ts","lineNumber":68,"sourceCode":"\tuserCode: string;\n\tintervalSeconds: number;\n};\n\ntype DeviceTokenSuccess = {\n\tauthorizationCode: string;\n\tcodeVerifier: string;\n};\n\ntype JwtPayload = {\n\t[JWT_CLAIM_PATH]?: {\n\t\tchatgpt_account_id?: string;\n\t};\n\t[key: string]: unknown;\n};\n\nfunction createState(): string {\n\tif (!_randomBytes) {\n\t\tthrow new Error(\"OpenAI Codex OAuth is only available in Node.js environments\");\n\t}\n\treturn _randomBytes(16).toString(\"hex\");\n}\n\nfunction parseAuthorizationInput(input: string): { code?: string; state?: string } {\n\tconst value = input.trim();\n\tif (!value) return {};\n\n\ttry {\n\t\tconst url = new URL(value);\n\t\treturn {\n\t\t\tcode: url.searchParams.get(\"code\") ?? undefined,\n\t\t\tstate: url.searchParams.get(\"state\") ?? undefined,\n\t\t};\n\t} catch {\n\t\t// not a URL\n\t}\n","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/ai/src/auth/oauth/openai-codex.ts#L50-L86","documentation":"createState needs cryptographically random bytes but the Node crypto randomBytes shim (_randomBytes) was never loaded. Fires when Codex OAuth login runs in a non-Node runtime that cannot supply randomness.","triggerScenarios":"Thrown at packages/ai/src/auth/oauth/openai-codex.ts:68 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run OpenAI Codex OAuth login in a Node.js environment."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}