{"record":{"id":"0696cc2ded2b4eeb","repo":"diegosouzapw/OmniRoute","slug":"native-codex-thread-id-and-turn-id-are-required","errorCode":null,"errorMessage":"Native Codex thread_id and turn_id are required","messagePattern":"Native Codex thread_id and turn_id are required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"open-sse/executors/chatgpt-web-codex.ts","lineNumber":114,"sourceCode":"  const candidates = [\n    explicit,\n    process.env.CHATGPT_WEB_CODEX_CHROME_PATH,\n    process.env.CHROME_PATH,\n    \"/usr/bin/google-chrome\",\n    \"/usr/bin/google-chrome-stable\",\n    \"/usr/bin/chromium\",\n    \"/usr/bin/chromium-browser\",\n    \"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\",\n  ];\n  return candidates.find((candidate): candidate is string =>\n    Boolean(candidate && existsSync(candidate))\n  );\n}\n\nfunction responseStateNamespace(connectionId: string, parsed: CodexParsedRequest): string {\n  const identity = extractChatGptTurnIdentity(parsed);\n  if (!identity.threadId || !identity.turnId) {\n    throw new Error(\"Native Codex thread_id and turn_id are required\");\n  }\n  return `${connectionId}:${identity.threadId}:${identity.turnId}`;\n}\n\nfunction previousResponseBelongsToTurn(\n  body: Record<string, unknown>,\n  connectionId: string,\n  parsed: CodexParsedRequest\n): boolean {\n  if (typeof body.previous_response_id !== \"string\" || !body.previous_response_id.trim()) {\n    return true;\n  }\n  try {\n    const namespace = responseStateNamespace(connectionId, parsed);\n    const expanded = expandPreviousResponseInput(body, namespace);\n    return expanded !== body;\n  } catch {\n    return false;","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/open-sse/executors/chatgpt-web-codex.ts#L96-L132","documentation":"Guard in the chatgpt-web-codex response-state logic: extractChatGptTurnIdentity(parsed) failed to yield both a threadId and a turnId for the native Codex request. The parsed request body is at fault — it is missing or has malformed native identifiers, so previous-response state cannot be namespaced per connection.","triggerScenarios":"Thrown at open-sse/executors/chatgpt-web-codex.ts:114 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the client sends well-formed native Codex thread_id and turn_id in the request","Regenerate the request instead of replaying a partially-copied payload","Update the Codex client so its requests always carry both identifiers"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}