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

Error "before thread cannot be specified without a section" thrown in openai/codex.

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)

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.