zeroclaw-labs/zeroclaw · error
Failed to create devices table
Error message
Failed to create devices table
What it means
Panic-style fatal error in the pairing DeviceRegistry constructor: the SQL batch that opens WAL mode and creates the devices table failed. This happens during gateway startup when the devices.db file is corrupt, the schema DDL is rejected, or the SQLite file is not writable. Because pairing cannot function without the table, the registry treats this as an unrecoverable startup invariant and panics. Check workspace write permissions and remove/repair devices.db.
Solutions
- Ensure the device registry database is writable and not corrupted; restart the gateway to retry table creation.
- Remove or restore a corrupted registry database file from backup and let it be recreated.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/zeroclaw-gateway/src/api_pairing.rs:58 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23).
Data as JSON: /api/errors/29a4527c9623820b.
Report an issue: GitHub.
Appendix: source
Thrown at crates/zeroclaw-gateway/src/api_pairing.rs:58
pub fn new(workspace_dir: &Path) -> Self {
let db_path = workspace_dir.join("devices.db");
let conn = Connection::open(&db_path).expect("Failed to open device registry database");
conn.execute_batch(
"PRAGMA journal_mode = WAL;
PRAGMA synchronous = NORMAL;
PRAGMA temp_store = MEMORY;
CREATE TABLE IF NOT EXISTS devices (
token_hash TEXT PRIMARY KEY,
id TEXT NOT NULL,
name TEXT,
device_type TEXT,
paired_at TEXT NOT NULL,
last_seen TEXT NOT NULL,
ip_address TEXT,
capabilities TEXT
)",
)
.expect("Failed to create devices table");
// Additive migration for DBs created before the capabilities column existed.
// SQLite has no IF NOT EXISTS for columns; the duplicate-column error here is benign.
let _ = conn.execute("ALTER TABLE devices ADD COLUMN capabilities TEXT", []);
// Warm the in-memory cache from DB
let mut cache = HashMap::new();
let mut stmt = conn
.prepare("SELECT token_hash, id, name, device_type, paired_at, last_seen, ip_address, capabilities FROM devices")
.expect("Failed to prepare device select");
let rows = stmt
.query_map([], |row| {
let token_hash: String = row.get(0)?;
let id: String = row.get(1)?;
let name: Option<String> = row.get(2)?;
let device_type: Option<String> = row.get(3)?;
let paired_at_str: String = row.get(4)?;
let last_seen_str: String = row.get(5)?;View on GitHub (pinned to 88bb9c8533)