{"record":{"id":"e7daf9bc06217420","repo":"openai/codex","slug":"thread-not-found-thread-id","errorCode":null,"errorMessage":"thread not found: {thread_id}","messagePattern":"thread not found: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/state/src/runtime/projects.rs","lineNumber":181,"sourceCode":"            .await?;\n            let Some(row) = row else {\n                tx.rollback().await?;\n                anyhow::bail!(\"idempotency key refers to deleted project: {idempotency_key}\");\n            };\n            let project = project_from_row_in_tx(&mut tx, &row).await?;\n            tx.commit().await?;\n            return Ok(CreatedProject {\n                project,\n                created: false,\n            });\n        }\n        for thread_id in thread_ids {\n            let exists = sqlx::query_scalar::<_, i64>(\"SELECT COUNT(*) FROM threads WHERE id = ?\")\n                .bind(thread_id)\n                .fetch_one(&mut *tx)\n                .await?;\n            if exists == 0 {\n                anyhow::bail!(\"thread not found: {thread_id}\");\n            }\n        }\n        let id = Uuid::now_v7().to_string();\n        let now = chrono::Utc::now().timestamp_millis();\n        let position = sqlx::query_scalar::<_, Option<i64>>(\"SELECT MAX(position) FROM projects\")\n            .fetch_one(&mut *tx)\n            .await?\n            .unwrap_or(-1)\n            .checked_add(1)\n            .ok_or_else(|| anyhow::anyhow!(\"project position overflow\"))?;\n        let metadata_json = serde_json::to_string(&metadata)?;\n        sqlx::query(\n            \"INSERT INTO projects (id, name, metadata, position, created_at_ms, updated_at_ms) VALUES (?, ?, ?, ?, ?, ?)\",\n        )\n        .bind(&id)\n        .bind(&name)\n        .bind(&metadata_json)\n        .bind(position)","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/state/src/runtime/projects.rs#L163-L199","documentation":"During create_project, one of the thread_ids supplied for association does not exist in the threads table (COUNT(*) == 0). The caller passed a thread id that was never created, was deleted, or is typo'd.","triggerScenarios":"Thrown at codex-rs/state/src/runtime/projects.rs:181 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the thread id exists via thread read before calling create_project","Create the thread first, then associate it with the project","Remove the stale thread id from the request"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}