{"record":{"id":"09f4d67f73255fc0","repo":"spacedriveapp/spacedrive","slug":"unknown-format-use-json-sql-or-markdown","errorCode":null,"errorMessage":"Unknown format: {}. Use json, sql, or markdown","messagePattern":"Unknown format: (.+?)\\. Use json, sql, or markdown","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"apps/cli/src/domains/sync/mod.rs","lineNumber":481,"sourceCode":"\t\tpeer_id: query.peer_filter,\n\t\tmodel_type: query.model_type_filter,\n\t\tcorrelation_id: query.correlation_id,\n\t\tlimit: query.limit,\n\t\toffset: query.offset,\n\t\tinclude_remote_peers: if args.all_devices { Some(true) } else { None },\n\t};\n\n\tlet json_response = ctx.core.query(&input, Some(library_id)).await?;\n\tlet output: sd_core::ops::sync::get_event_log::GetSyncEventLogOutput =\n\t\tserde_json::from_value(json_response)?;\n\n\t// Format output\n\tlet formatted = match args.format.as_str() {\n\t\t\"json\" => format_events_json(&output.events, args.with_device)?,\n\t\t\"sql\" => format_events_sql(&output.events),\n\t\t\"markdown\" | \"md\" => format_events_markdown(&output.events, args.with_device),\n\t\t_ => {\n\t\t\treturn Err(anyhow::anyhow!(\n\t\t\t\t\"Unknown format: {}. Use json, sql, or markdown\",\n\t\t\t\targs.format\n\t\t\t))\n\t\t}\n\t};\n\n\t// Write output\n\tif let Some(output_file) = &args.output {\n\t\tstd::fs::write(output_file, formatted)?;\n\t\tprintln!(\"Exported {} events to {}\", output.events.len(), output_file);\n\t} else {\n\t\tprintln!(\"{}\", formatted);\n\t}\n\n\tOk(())\n}\n\nfn format_events_json(","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/apps/cli/src/domains/sync/mod.rs#L463-L499","documentation":"'sd sync events export --format <value>' only accepts json, sql, markdown (md is an alias). Any other string reaches the catch-all arm and returns this error before any output is written.","triggerScenarios":"Passing --format csv, txt, table, yaml, or a typo like 'jso' or 'Markdown' (matching is case-sensitive).","commonSituations":"Scripts assuming a format the tool never supported; uppercase first letter; trailing whitespace in shell variables.","solutions":["Use --format json, sql, or markdown (md also works)","If you need another format, export as json and convert downstream with jq or similar"],"exampleFix":"# before\nsd sync events export --format csv\n\n# after\nsd sync events export --format json | jq .","handlingStrategy":"validation","validationCode":"fn is_valid_format(s: &str) -> bool {\n    matches!(s, \"json\" | \"sql\" | \"markdown\" | \"md\")\n}","typeGuard":"fn as_format(s: &str) -> Option<&'static str> {\n    match s {\n        \"json\" => Some(\"json\"),\n        \"sql\" => Some(\"sql\"),\n        \"markdown\" | \"md\" => Some(\"markdown\"),\n        _ => None,\n    }\n}","tryCatchPattern":"let Some(fmt) = as_format(&args.format) else {\n    return Err(anyhow!(\"Unknown format: {}. Use json, sql, or markdown\", args.format));\n};","preventionTips":["Declare the format flag as a clap enum so clap rejects invalid values with usage help","Trim and lowercase the flag value before matching","Document 'md' as an alias so users are not surprised by case sensitivity"],"tags":["cli","sync","validation","formatting"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}