spacedriveapp/spacedrive · error · anyhow::Error
Invalid severity: {}
Error message
Invalid severity: {} What it means
'sd sync events export --severity <value>' fails when the value is not one of the four names accepted by EventSeverity::from_str (core/src/infra/sync/event_log/types.rs:274): debug, info, warning, error. The match is exact and case-sensitive despite the display code using colored output.
Source
Thrown at apps/cli/src/domains/sync/mod.rs:452
if let Some(event_type) = SyncEventType::from_str(event_type_str) {
query = query.with_event_types(vec![event_type]);
} else {
return Err(anyhow::anyhow!("Invalid event type: {}", event_type_str));
}
}
// Parse correlation ID filter
if let Some(corr_id_str) = &args.correlation_id {
let corr_id = uuid::Uuid::parse_str(corr_id_str)?;
query = query.with_correlation_id(corr_id);
}
// Parse severity filter
if let Some(severity_str) = &args.severity {
if let Some(severity) = EventSeverity::from_str(severity_str) {
query = query.with_severities(vec![severity]);
} else {
return Err(anyhow::anyhow!("Invalid severity: {}", severity_str));
}
}
// Call the API
let input = sd_core::ops::sync::get_event_log::GetSyncEventLogInput {
start_time: query.time_range.map(|(start, _)| start),
end_time: query.time_range.map(|(_, end)| end),
event_types: query.event_types,
categories: query.categories,
severities: query.severities,
peer_id: query.peer_filter,
model_type: query.model_type_filter,
correlation_id: query.correlation_id,
limit: query.limit,
offset: query.offset,
include_remote_peers: if args.all_devices { Some(true) } else { None },
};
View on GitHub (pinned to 6dfeccf211)
Solutions
- Use an exact lowercase value: --severity debug|info|warning|error
- Drop the filter and post-filter the JSON output by the severity field to discover valid names
Example fix
# before sd sync events export --severity warn # after sd sync events export --severity warning
Defensive patterns
Strategy: validation
Validate before calling
const VALID_SEVERITIES: &[&str] = &["debug", "info", "warning", "error"];
fn is_valid_severity(s: &str) -> bool {
VALID_SEVERITIES.contains(&s.to_ascii_lowercase().as_str())
} Type guard
fn as_severity(s: &str) -> Option<EventSeverity> {
EventSeverity::from_str(s.to_ascii_lowercase().as_str())
} Try / catch
let Some(severity) = EventSeverity::from_str(&severity_str.to_ascii_lowercase()) else {
return Err(anyhow!("Invalid severity: {}. Use debug, info, warning, or error", severity_str));
};
query = query.with_severities(vec![severity]); Prevention
- Accept common aliases (warn -> warning) at the CLI boundary before calling from_str
- Use clap's PossibleValues/ValueEnum for the flag so invalid values are rejected at parse time
- Lowercase input before validation
When it happens
Trigger: Passing 'warn', 'ERROR', 'Info', 'fatal', or any string other than the exact lowercase names.
Common situations: Habitual use of log-level spellings from other ecosystems (warn, err, critical); uppercase values copied from log output.
Related errors
- Invalid event type: {}
- Unknown format: {}. Use json, sql, or markdown
- Failed to build action: {}
- No paired devices found. Pair a device first with: sd networ
- Remote device {} is not online
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/77ee2d2e8ee80b52.
Report an issue: GitHub.