tinyhumansai/openhuman · error · anyhow::Error
device not found after insert
Error message
device not found after insert
What it means
A device row was inserted into `paired_devices` (INSERT OR REPLACE reported success) but the immediate follow-up read of that device found nothing. This is an internal consistency check in `insert_device`: the row should be readable in the same connection/transaction, so a miss implies the insert silently no-oped or the read query diverges from the write — a store-level invariant break, not caller input.
Source
Thrown at src/openhuman/security/devices/store.rs:45
let now = Utc::now().to_rfc3339();
with_connection(config, |conn| {
conn.execute(
"INSERT OR REPLACE INTO paired_devices \
(channel_id, label, device_pubkey, core_session_token_hash, \
shared_secret_encrypted, created_at, last_seen_at, revoked) \
VALUES (?1, ?2, ?3, ?4, NULL, ?5, NULL, 0)",
params![
channel_id,
label,
device_pubkey,
core_session_token_hash,
now
],
)
.context("insert_device: INSERT failed")?;
Ok(())
})?;
get_device(config, channel_id)?.ok_or_else(|| anyhow::anyhow!("device not found after insert"))
}
/// Update `last_seen_at` for a device (called on `tunnel:peer-status` online events).
pub fn touch_device(config: &Config, channel_id: &str) -> Result<()> {
let now = Utc::now().to_rfc3339();
with_connection(config, |conn| {
conn.execute(
"UPDATE paired_devices SET last_seen_at = ?1 WHERE channel_id = ?2 AND revoked = 0",
params![now, channel_id],
)
.context("touch_device: UPDATE failed")?;
Ok(())
})
}
/// Mark a device as revoked (soft delete).
pub fn revoke_device(config: &Config, channel_id: &str) -> Result<bool> {
let rows = with_connection(config, |conn| {View on GitHub (pinned to 7491200858)
Solutions
- Check the SQLite schema matches the INSERT column set (migration drift)
- Verify no trigger or constraint silently discarded the row
- Inspect store logs around the insert/read pair
- Retry the pairing operation after confirming schema integrity
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at src/openhuman/security/devices/store.rs:45 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17).
Data as JSON: /api/errors/c47b21a7a671a59b.
Report an issue: GitHub.