{"record":{"id":"0a4dadc1fed97c84","repo":"GitoxideLabs/gitoxide","slug":"json-output-isn-t-supported-0a4dad","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/remote.rs","lineNumber":49,"sourceCode":"pub struct RefsWriteOutcome {\n    pub num_refs: usize,\n    pub elapsed: Duration,\n}\n\npub fn refs<P, W>(\n    protocol: Option<net::Protocol>,\n    url: &str,\n    refs_directory: Option<PathBuf>,\n    mut progress: P,\n    ctx: Context<W>,\n) -> anyhow::Result<()>\nwhere\n    W: io::Write,\n    P: NestedProgress + 'static,\n    P::SubProgress: 'static,\n{\n    if ctx.format != OutputFormat::Human {\n        bail!(\"JSON output isn't supported\");\n    }\n\n    let mut transport = net::connect(\n        url,\n        connect::Options {\n            version: protocol.unwrap_or_default().into(),\n            ..Default::default()\n        },\n    )?;\n    let trace_packetlines = std::env::var_os(\n        gix::config::tree::Gitoxide::TRACE_PACKET\n            .environment_override()\n            .expect(\"set\"),\n    )\n    .is_some();\n\n    progress.info(format!(\"Connecting to {url:?}\"));\n    let agent = protocol::agent(gix::env::agent());","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gitoxide-core/src/remote.rs#L31-L67","documentation":"The remote `refs` command (gitoxide-core remoterefs) only implements human-readable output; if the caller passes any OutputFormat other than Human (e.g. JSON), it bails immediately before connecting to the remote. JSON serialization of fetched refs is simply not implemented for this subcommand.","triggerScenarios":"Calling `remote::refs` with `ctx.format == OutputFormat::Json` - e.g. running the CLI subcommand with a `--format json` style flag that reaches this function.","commonSituations":"Scripting the CLI expecting machine-readable JSON output for remote refs; IDE/tooling integrations requesting JSON uniformly across all gix subcommands.","solutions":["Use the default human output format and parse it if needed","Use the `gix` library API directly (gix::remote) and serialize the refs to JSON in your own code","Check which subcommands support JSON and file an upstream feature request for remote refs JSON output"],"exampleFix":"// before\nlet ctx = Context { format: OutputFormat::Json, .. };\nremote::refs(url, repo_path, protocol, out, ctx)?;\n// after\nlet ctx = Context { format: OutputFormat::Human, .. };\nremote::refs(url, repo_path, protocol, out, ctx)?;","handlingStrategy":"validation","validationCode":"if ctx.format != OutputFormat::Human {\n    eprintln!(\"remote refs supports only human output; falling back\");\n    ctx.format = OutputFormat::Human;\n}","typeGuard":null,"tryCatchPattern":"match remote::refs(url, repo, protocol, out, ctx) {\n    Err(e) if e.to_string().contains(\"JSON output isn't supported\") => {\n        // rerun with Human or parse human output\n    }\n    other => other?,\n}","preventionTips":["Check per-subcommand format support before requesting JSON","Default to Human output for remote refs","Serialize library-level results yourself instead of relying on CLI JSON"],"tags":["cli","output-format","json","unsupported-feature"],"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-15T23:17:13.987Z"}