spacedriveapp/spacedrive · error
Invalid severity: {}
Error message
Invalid severity: {} What it means
Row mapper at core/src/infra/sync/event_log/logger.rs:196 parses sync_event_log.severity via EventSeverity::from_str, which accepts exactly: debug, info, warning, error. Any other severity string fails the row conversion and surfaces as this anyhow error when listing sync events.
Source
Thrown at core/src/infra/sync/event_log/logger.rs:196
let severity_str: String = row.try_get("", "severity")?;
let summary: String = row.try_get("", "summary")?;
let details_str: Option<String> = row.try_get("", "details").ok();
let correlation_id_str: Option<String> = row.try_get("", "correlation_id").ok();
let peer_device_id_str: Option<String> = row.try_get("", "peer_device_id").ok();
let model_types_str: Option<String> = row.try_get("", "model_types").ok();
let record_count: Option<i64> = row.try_get("", "record_count").ok();
let duration_ms: Option<i64> = row.try_get("", "duration_ms").ok();
Ok(SyncEventLog {
id: Some(id),
timestamp: DateTime::parse_from_rfc3339(×tamp_str)?.with_timezone(&Utc),
device_id: Uuid::parse_str(&device_id_str)?,
event_type: SyncEventType::from_str(&event_type_str)
.ok_or_else(|| anyhow::anyhow!("Invalid event type: {}", event_type_str))?,
category: EventCategory::from_str(&category_str)
.ok_or_else(|| anyhow::anyhow!("Invalid category: {}", category_str))?,
severity: EventSeverity::from_str(&severity_str)
.ok_or_else(|| anyhow::anyhow!("Invalid severity: {}", severity_str))?,
summary,
details: details_str
.as_ref()
.and_then(|s| serde_json::from_str(s).ok()),
correlation_id: correlation_id_str
.as_ref()
.and_then(|s| Uuid::parse_str(s).ok()),
peer_device_id: peer_device_id_str
.as_ref()
.and_then(|s| Uuid::parse_str(s).ok()),
model_types: model_types_str.map(|s| s.split(',').map(|t| t.to_string()).collect()),
record_count: record_count.map(|c| c as u64),
duration_ms: duration_ms.map(|d| d as u64),
})
}
/// Clean up old events (called by pruning task)
pub async fn cleanup_old_events(&self, older_than: DateTime<Utc>) -> Result<usize> {View on GitHub (pinned to 6dfeccf211)
Solutions
- Audit values: `SELECT DISTINCT severity FROM sync_event_log;`.
- Normalize or delete offending rows: UPDATE sync_event_log SET severity='warning' WHERE severity='warn';
- Fix fixtures/scripts to use EventSeverity::as_str() tokens; add legacy arms to from_str if you rename severities.
Example fix
# before sqlite> SELECT DISTINCT severity FROM sync_event_log; warn # after sqlite> UPDATE sync_event_log SET severity='warning' WHERE severity='warn';
Defensive patterns
Strategy: validation
Validate before calling
// normalize before insert (e.g. adapting log-level spellings)
fn severity_token(s: &str) -> Option<&'static str> {
match s.to_ascii_lowercase().as_str() {
"warn" | "warning" => Some("warning"),
"debug" | "info" | "error" => Some(match s { "debug" => "debug", "info" => "info", _ => "error" }),
_ => None,
}
} Type guard
fn is_known_severity(s: &str) -> bool {
EventSeverity::from_str(s).is_some()
} Try / catch
// tolerate unknown severities at read time
let severity = match EventSeverity::from_str(&severity_str) {
Some(s) => s,
None => { tracing::warn!(severity = %severity_str, "unknown severity"); continue; }
}; Prevention
- Write severity with EventSeverity::as_str() only (debug/info/warning/error).
- Do not reuse RUST_LOG level names ('warn', 'trace') in the column.
- Extend from_str with aliases when severities evolve.
When it happens
Trigger: A sync_event_log row with severity 'warn', 'ERROR', 'critical', or an empty string — anything not the four exact lowercase tokens. Core writes only via EventSeverity::as_str(), so real triggers are external inserts, fixtures, or a modified enum on another build.
Common situations: Test fixtures using log-level spellings ('warn' from tracing/RUST_LOG); manual INSERTs; another daemon version with extra severity levels.
Related errors
- Invalid event type: {}
- Invalid category: {}
- Failed to deserialize sync response: {}
- Failed to deserialize sync response: {}
- Failed to query library devices: {}
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/8162d2120c69f19d.
Report an issue: GitHub.