openai/codex · error · anyhow::Error
before project not found
Error message
before project not found: {before_project_id} What it means
move_project was given a before_project_id that is not present in the ordered project list fetched from the projects table. The anchor project for the reorder does not exist (deleted, never created, or wrong id).
Solutions
- Refresh the project list and use a valid before_project_id
- Create the anchor project before reordering
- Pass None to move the project to the beginning instead
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at codex-rs/state/src/runtime/projects.rs:318 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/ec6e85b89c049d69.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/state/src/runtime/projects.rs:318
"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 = ?")
.bind(position as i64)
.bind(id)
.execute(&mut *tx)
.await?;
}
sqlx::query("UPDATE projects SET updated_at_ms = ? WHERE id = ?")
.bind(chrono::Utc::now().timestamp_millis())
.bind(project_id)View on GitHub (pinned to 339751715c)