{"record":{"id":"70ebead795b5af9d","repo":"openai/codex","slug":"thread-thread-id-cannot-be-moved-before-itself","errorCode":null,"errorMessage":"thread {thread_id} cannot be moved before itself","messagePattern":"thread (.+?) cannot be moved before itself","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/state/src/runtime/thread_section_order.rs","lineNumber":149,"sourceCode":"            .bind(&thread_id)\n            .execute(&mut *tx)\n            .await?;\n            tx.commit().await?;\n            return Ok(true);\n        };\n\n        if sqlx::query_scalar::<_, i64>(\"SELECT 1 FROM thread_sections WHERE id = ?\")\n            .bind(section)\n            .fetch_optional(&mut *tx)\n            .await?\n            .is_none()\n        {\n            return Err(anyhow::anyhow!(\"section {section} does not exist\"));\n        }\n\n        let before_thread_id = before_thread_id.map(|id| id.to_string());\n        if before_thread_id.as_deref() == Some(thread_id.as_str()) {\n            return Err(anyhow::anyhow!(\n                \"thread {thread_id} cannot be moved before itself\"\n            ));\n        }\n\n        if let Some(before_thread_id) = before_thread_id.as_deref() {\n            let before_section = sqlx::query_scalar::<_, Option<String>>(\n                \"SELECT thread_section_id FROM threads WHERE id = ?\",\n            )\n            .bind(before_thread_id)\n            .fetch_optional(&mut *tx)\n            .await?;\n            if before_section.flatten().as_deref() != Some(section) {\n                return Err(anyhow::anyhow!(\n                    \"before thread {before_thread_id} is not in section {section}\"\n                ));\n            }\n        }\n","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/state/src/runtime/thread_section_order.rs#L131-L167","documentation":"Error \"thread {thread_id} cannot be moved before itself\" thrown in openai/codex.","triggerScenarios":"Thrown at codex-rs/state/src/runtime/thread_section_order.rs:149 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}