{"record":{"id":"eede44cf4c0f9d1c","repo":"spacedriveapp/spacedrive","slug":"unknown-time-unit","errorCode":null,"errorMessage":"Unknown time unit: {}","messagePattern":"Unknown time unit: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"apps/cli/src/domains/sync/mod.rs","lineNumber":170,"sourceCode":"\nfn parse_duration(duration_str: &str) -> Result<chrono::Duration> {\n\tlet parts: Vec<&str> = duration_str.split_whitespace().collect();\n\tif parts.len() != 2 {\n\t\treturn Err(anyhow::anyhow!(\"Invalid duration format: {}\", duration_str));\n\t}\n\n\tlet value: i64 = parts[0]\n\t\t.parse()\n\t\t.map_err(|_| anyhow::anyhow!(\"Invalid number: {}\", parts[0]))?;\n\tlet unit = parts[1].to_lowercase();\n\n\tlet seconds = match unit.as_str() {\n\t\t\"second\" | \"seconds\" | \"sec\" | \"s\" => value,\n\t\t\"minute\" | \"minutes\" | \"min\" | \"m\" => value * 60,\n\t\t\"hour\" | \"hours\" | \"h\" => value * 3600,\n\t\t\"day\" | \"days\" | \"d\" => value * 86400,\n\t\t\"week\" | \"weeks\" | \"w\" => value * 604800,\n\t\t_ => return Err(anyhow::anyhow!(\"Unknown time unit: {}\", unit)),\n\t};\n\n\tOk(chrono::Duration::seconds(seconds))\n}\n\nfn display_metrics(\n\tsnapshot: &sd_core::service::sync::metrics::snapshot::SyncMetricsSnapshot,\n\targs: &SyncMetricsArgs,\n) {\n\t// Status header box\n\tlet status_icon = match snapshot.state.current_state {\n\t\tDeviceSyncState::Ready => \"●\".green(),\n\t\tDeviceSyncState::Backfilling { .. } => \"◐\".yellow(),\n\t\tDeviceSyncState::CatchingUp { .. } => \"◔\".yellow(),\n\t\tDeviceSyncState::Uninitialized => \"○\".dark_grey(),\n\t\tDeviceSyncState::Paused => \"◦\".dark_grey(),\n\t};\n","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/apps/cli/src/domains/sync/mod.rs#L152-L188","documentation":"Thrown by parse_duration() when the unit token (lowercased) does not match any arm of its match statement. Supported units are second(s)/sec/s, minute(s)/min/m, hour(s)/h, day(s)/d, and week(s)/w. Notably there is no month or year arm, and multi-word or plural-creative forms like 'fortnights' fail too.","triggerScenarios":"--since '1 month ago', '--since \"2 years ago\"', '--since \"90 secs\" (note: secs is NOT in the list - only second/seconds/sec/s), '--since \"3 hrs ago\"' (hrs unsupported; use h/hours).","commonSituations":"Assuming month/year granularity exists; abbreviations that differ from the accepted set ('secs', 'hrs', 'mins' - only 'min' and 'm' are listed for minutes); composing durations like '1 day 6 hours'.","solutions":["Convert unsupported units to supported ones: '1 month ago' -> '30 days ago', '1 year ago' -> '52 weeks ago'","Use the exact accepted abbreviations: s, m, h, d, w (or full words: seconds, minutes, hours, days, weeks)","Use one value-unit pair only; sum multiple durations into a single unit first"],"exampleFix":"// accepted units: second|seconds|sec|s, minute|minutes|min|m,\n//                 hour|hours|h, day|days|d, week|weeks|w\n// before (fails): sd sync metrics --since '1 month ago'\n// after:           sd sync metrics --since '30 days ago'","handlingStrategy":"validation","validationCode":"const SUPPORTED_UNITS: &[&str] = &[\n    \"second\", \"seconds\", \"sec\", \"s\",\n    \"minute\", \"minutes\", \"min\", \"m\",\n    \"hour\", \"hours\", \"h\",\n    \"day\", \"days\", \"d\",\n    \"week\", \"weeks\", \"w\",\n];\n\nlet unit = duration_str.split_whitespace().nth(1).unwrap_or(\"\").to_lowercase();\nif !SUPPORTED_UNITS.contains(&unit.as_str()) {\n    eprintln!(\"Unit '{}' not supported. Use one of: {} (no months/years)\", unit, SUPPORTED_UNITS.join(\", \"));\n    return Ok(());\n}","typeGuard":"fn is_supported_unit(u: &str) -> bool {\n    matches!(\n        u.to_lowercase().as_str(),\n        \"second\" | \"seconds\" | \"sec\" | \"s\"\n            | \"minute\" | \"minutes\" | \"min\" | \"m\"\n            | \"hour\" | \"hours\" | \"h\"\n            | \"day\" | \"days\" | \"d\"\n            | \"week\" | \"weeks\" | \"w\"\n    )\n}","tryCatchPattern":null,"preventionTips":["Convert months (~30 days) and years (~52 weeks) into supported units yourself","Stick to the canonical abbreviations s/m/h/d/w - 'secs', 'hrs', 'mins' are not all accepted","Use exactly one value-unit pair; '1 day 6 hours' is not a valid single duration"],"tags":["cli","sync","time-parsing","duration"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}