{"record":{"id":"013d48ceebe988f7","repo":"GitoxideLabs/gitoxide","slug":"json-output-isn-t-supported","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/lib.rs","lineNumber":102,"sourceCode":"\nmod output;\n\nmod discover;\npub use discover::discover;\n\npub fn trust(paths: &[std::path::PathBuf], mut out: impl std::io::Write) -> anyhow::Result<()> {\n    let trust_width = \"Reduced\".len();\n    for path in paths {\n        let trust = gix::sec::Trust::from_path_ownership(path)?;\n        let trust = format!(\"{trust:?}\");\n        writeln!(out, \"{trust:<trust_width$} {}\", path.display())?;\n    }\n    Ok(())\n}\n\npub fn env(mut out: impl std::io::Write, format: OutputFormat) -> anyhow::Result<()> {\n    if format != OutputFormat::Human {\n        bail!(\"JSON output isn't supported\");\n    }\n\n    let width = 15;\n    writeln!(\n        out,\n        \"{field:>width$}: {}\",\n        std::path::Path::new(gix::path::env::shell()).display(),\n        field = \"shell\",\n    )?;\n    writeln!(\n        out,\n        \"{field:>width$}: {:?}\",\n        gix::path::env::installation_config_prefix(),\n        field = \"config prefix\",\n    )?;\n    writeln!(\n        out,\n        \"{field:>width$}: {:?}\",","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gitoxide-core/src/lib.rs#L84-L120","documentation":"Guard clause in the `env` command handler of gitoxide-core. The CLI `ein tool env` command only implements human-readable rendering of the resolved git environment; when the caller passes `--format json` (OutputFormat not Human), the function aborts via anyhow::bail! instead of silently emitting human output. It fires whenever a user or script requests JSON serialization of environment output, which has no serializer implemented. Fix is either to implement a JSON serializer for the env output or accept the limitation and use the default human format.","triggerScenarios":"Calling `gix_core::env(out, OutputFormat::Json)` or running the corresponding CLI command with `--format json`.","commonSituations":"Scripts that uniformly pass a JSON format flag to all gix subcommands; assuming feature parity of output formats across commands.","solutions":["Use the default human output format for the env command","Drop the `--format json` flag from the command line","If machine-readable output is needed, parse the human output or add JSON support upstream"],"exampleFix":"// before\ngix env --format json\n// after\ngix env","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = gix_core::env(&mut out, format) {\n    if format != OutputFormat::Human {\n        gix_core::env(&mut out, OutputFormat::Human)?;\n    } else { return Err(e); }\n}","preventionTips":["Only use OutputFormat::Human with env","Document format limitations per subcommand in scripts"],"tags":["cli","output-format","unsupported","git"],"backgroundTag":"unsupported-operation","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}