{"record":{"id":"5fabb05dfb97e343","repo":"GitoxideLabs/gitoxide","slug":"json-output-isn-t-supported-5fabb0","errorCode":null,"errorMessage":"JSON output isn't supported","messagePattern":"JSON output isn't supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitoxide-core/src/repository/branch.rs","lineNumber":21,"sourceCode":"pub mod list {\n    pub enum Kind {\n        Local,\n        All,\n    }\n\n    pub struct Options {\n        pub kind: Kind,\n    }\n}\n\npub fn list(\n    repo: gix::Repository,\n    out: &mut dyn std::io::Write,\n    format: OutputFormat,\n    options: list::Options,\n) -> anyhow::Result<()> {\n    if format != OutputFormat::Human {\n        anyhow::bail!(\"JSON output isn't supported\");\n    }\n\n    let platform = repo.references()?;\n\n    let (show_local, show_remotes) = match options.kind {\n        list::Kind::Local => (true, false),\n        list::Kind::All => (true, true),\n    };\n\n    if show_local {\n        let mut branch_names: Vec<String> = platform\n            .local_branches()?\n            .flatten()\n            .map(|branch| branch.name().shorten().to_string())\n            .collect();\n\n        branch_names.sort();\n","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gitoxide-core/src/repository/branch.rs#L3-L39","documentation":"The branch `list` command supports only human-readable output; a non-Human OutputFormat (e.g. JSON) bails before enumerating references. JSON serialization for branch listing is not implemented in gitoxide-core.","triggerScenarios":"Calling `repository::branch::list` with `format != OutputFormat::Human`, e.g. the CLI branch listing invoked with a JSON format flag.","commonSituations":"Scripts or tools expecting machine-readable branch listings from gix; IDE integrations requesting JSON output uniformly.","solutions":["Use the human output format and parse the text","Enumerate branches via the gix library (`repo.references()?` / remote refs) and serialize to JSON yourself","File or track an upstream feature request for JSON branch output"],"exampleFix":"// before\nbranch::list(repo, &mut out, OutputFormat::Json, options)?;\n// after\nbranch::list(repo, &mut out, OutputFormat::Human, options)?;","handlingStrategy":"validation","validationCode":"if format != OutputFormat::Human {\n    eprintln!(\"branch list: JSON not supported; using Human\");\n    format = OutputFormat::Human;\n}","typeGuard":null,"tryCatchPattern":"match branch::list(repo, out, format, options) {\n    Err(e) if e.to_string().contains(\"JSON output isn't supported\") => {\n        // fall back to human output or use gix library refs API\n    }\n    other => other?,\n}","preventionTips":["Use Human output for branch listing","Enumerate branches via gix::Repository references API for structured data","Check format support per subcommand before invoking with JSON"],"tags":["cli","json","output-format","branches"],"backgroundTag":"operation-not-supported","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}