openai/codex · error · anyhow::Error
before thread cannot be specified without a section
Error message
before thread cannot be specified without a section
What it means
API-contract violation in move_thread_to_section: the caller passed before_thread_id (a target thread to insert ahead of) while supplying no section. Positioning within 'no section' is meaningless, so the request is rejected before any transaction work runs.
Solutions
- Pass a concrete section id together with before_thread_id when inserting at a position inside a section
- Pass section=None and before_thread_id=None to clear the thread's section (append semantics)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at codex-rs/state/src/runtime/thread_section_order.rs:111 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/18c8f507e328fa8a.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/state/src/runtime/thread_section_order.rs:111
None
};
Ok(crate::ThreadSectionsPage {
sections,
next_cursor,
})
}
/// Move a thread into or within a section, or clear its section.
///
/// Omitting `before_thread_id` appends the thread to its destination section.
pub async fn move_thread_to_section(
&self,
thread_id: ThreadId,
section: Option<&str>,
before_thread_id: Option<ThreadId>,
) -> anyhow::Result<bool> {
if section.is_none() && before_thread_id.is_some() {
return Err(anyhow::anyhow!(
"before thread cannot be specified without a section"
));
}
let mut tx = self.pool.begin_with("BEGIN IMMEDIATE").await?;
let thread_id = thread_id.to_string();
let current_section = sqlx::query_scalar::<_, Option<String>>(
"SELECT thread_section_id FROM threads WHERE id = ?",
)
.bind(&thread_id)
.fetch_optional(&mut *tx)
.await?;
let Some(current_section) = current_section else {
return Ok(false);
};
let Some(section) = section else {
sqlx::query(
"UPDATE threads SET thread_section_id = NULL, section_position = NULL, section_entered_at_ms = NULL WHERE id = ?",View on GitHub (pinned to 339751715c)