nikivdev/code · error
create table failed: {:?}
Error message
create table failed: {:?} What it means
ensure_schema executes the CREATE TABLE DDL for invocation records and maps any error other than TableExists to this anyhow error with the debug-formatted DatabaseError. It is thrown when the jazz2 table cannot be created for reasons other than it already existing.
Source
Thrown at src/jazz_state.rs:162
project_name STRING,
config_path STRING NOT NULL,
task STRING NOT NULL,
command STRING NOT NULL,
user_input STRING NOT NULL,
success BOOL NOT NULL,
status I64,
duration_ms I64 NOT NULL,
timestamp_ms I64 NOT NULL,
flow_version STRING NOT NULL,
used_flox BOOL NOT NULL,
output STRING NOT NULL
)
"#;
match db.execute(sql) {
Ok(_) => Ok(()),
Err(DatabaseError::TableExists(_)) => Ok(()),
Err(err) => Err(anyhow::anyhow!("create table failed: {:?}", err)),
}
}
fn insert_task_run(db: &Database, record: &InvocationRecord) -> Result<()> {
let status = record
.status
.map(|value| value.to_string())
.unwrap_or_else(|| "NULL".to_string());
let duration_ms = record.duration_ms.min(i64::MAX as u128) as i64;
let timestamp_ms = record.timestamp_ms.min(i64::MAX as u128) as i64;
let project_name = record
.project_name
.as_ref()
.map(|value| format!("'{}'", sql_escape(value)))
.unwrap_or_else(|| "NULL".to_string());
let output = truncate_output(&record.output, OUTPUT_LIMIT);
let sql = format!(View on GitHub (pinned to a747e741ae)
Solutions
- Check the debug DatabaseError in the message to identify the root cause (locked/disk-full/permission)
- Ensure the jazz2 file's directory is writable and has free space
- Close competing processes and retry, or run once alone to let the schema be created
- If the schema is incompatible, migrate or recreate the database
Example fix
// before
Err(err) => Err(anyhow::anyhow!("create table failed: {:?}", err)),
// after
Err(err) => Err(anyhow::anyhow!("create table failed: {err:#}")) // include full cause chain Defensive patterns
Strategy: try-catch
Validate before calling
// preflight: ensure db dir writable and space available
let dir = db_path.parent().unwrap_or(std::path::Path::new("."));
let probe = dir.join(".f-write-probe");
std::fs::write(&probe, b"")?;
std::fs::remove_file(&probe)?; Try / catch
match with_db(|db| ensure_schema(db)) {
Err(e) if e.to_string().starts_with("create table failed") => {
eprintln!("check jazz2 permissions/disk; cause: {e:#}");
}
other => other?,
} Prevention
- Create the schema once at startup, not per record
- Keep a stable DDL string across versions
- Ensure disk space and writability where jazz2 lives
- Handle TableExists (already done) and lock errors separately with retries
When it happens
Trigger: record_task_run → with_db → ensure_schema where db.execute(sql) fails with a non-TableExists error: syntax issue after migration, permission denied, disk full, or database locked.
Common situations: Older jazz2 file with incompatible schema, read-only DB location, concurrent writers during DDL, disk quota exceeded.
Related errors
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/0d30399a88d8cf59.
Report an issue: GitHub.