openai/codex · error · anyhow::Error
project {project_id} cannot be moved before itself
Error message
project {project_id} cannot be moved before itself What it means
Error "project {project_id} cannot be moved before itself" thrown in openai/codex.
Source
Thrown at codex-rs/state/src/runtime/projects.rs:310
/// Returns None when the moved project does not exist and Some(false) for a no-op.
pub async fn move_project(
&self,
project_id: &str,
before_project_id: Option<&str>,
) -> anyhow::Result<Option<bool>> {
let mut tx = self.pool.begin_with("BEGIN IMMEDIATE").await?;
let mut project_ids = sqlx::query_scalar::<_, String>(
"SELECT id FROM projects ORDER BY position ASC, id ASC",
)
.fetch_all(&mut *tx)
.await?;
let Some(current_index) = project_ids.iter().position(|id| id == project_id) else {
tx.rollback().await?;
return Ok(None);
};
if before_project_id == Some(project_id) {
tx.rollback().await?;
anyhow::bail!("project {project_id} cannot be moved before itself");
}
let original_project_ids = project_ids.clone();
project_ids.remove(current_index);
let next_index = if let Some(before_project_id) = before_project_id {
project_ids
.iter()
.position(|id| id == before_project_id)
.ok_or_else(|| anyhow::anyhow!("before project not found: {before_project_id}"))?
} else {
project_ids.len()
};
project_ids.insert(next_index, project_id.to_string());
if project_ids == original_project_ids {
tx.rollback().await?;
return Ok(Some(false));
}
for (position, id) in project_ids.iter().enumerate() {
sqlx::query("UPDATE projects SET position = ? WHERE id = ?")View on GitHub (pinned to 339751715c)
When it happens
Trigger: Thrown at codex-rs/state/src/runtime/projects.rs:310 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/f5b8129eeb83fce7.
Report an issue: GitHub.