GitoxideLabs/gitoxide · error

JSON output isn't supported

Error message

JSON output isn't supported

What it means

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.

Solutions

  1. Use the default human output format and parse it if needed
  2. Use the `gix` library API directly (gix::remote) and serialize the refs to JSON in your own code
  3. Check which subcommands support JSON and file an upstream feature request for remote refs JSON output

Example fix

// before
let ctx = Context { format: OutputFormat::Json, .. };
remote::refs(url, repo_path, protocol, out, ctx)?;
// after
let ctx = Context { format: OutputFormat::Human, .. };
remote::refs(url, repo_path, protocol, out, ctx)?;
Defensive patterns

Strategy: validation

Validate before calling

if ctx.format != OutputFormat::Human {
    eprintln!("remote refs supports only human output; falling back");
    ctx.format = OutputFormat::Human;
}

Try / catch

match remote::refs(url, repo, protocol, out, ctx) {
    Err(e) if e.to_string().contains("JSON output isn't supported") => {
        // rerun with Human or parse human output
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling `remote::refs` with `ctx.format == OutputFormat::Json` - e.g. running the CLI subcommand with a `--format json` style flag that reaches this function.

Common situations: Scripting the CLI expecting machine-readable JSON output for remote refs; IDE/tooling integrations requesting JSON uniformly across all gix subcommands.

Related errors


AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08). Data as JSON: /api/errors/0a4dadc1fed97c84. Report an issue: GitHub.

Appendix: source

Thrown at gitoxide-core/src/remote.rs:49

pub struct RefsWriteOutcome {
    pub num_refs: usize,
    pub elapsed: Duration,
}

pub fn refs<P, W>(
    protocol: Option<net::Protocol>,
    url: &str,
    refs_directory: Option<PathBuf>,
    mut progress: P,
    ctx: Context<W>,
) -> anyhow::Result<()>
where
    W: io::Write,
    P: NestedProgress + 'static,
    P::SubProgress: 'static,
{
    if ctx.format != OutputFormat::Human {
        bail!("JSON output isn't supported");
    }

    let mut transport = net::connect(
        url,
        connect::Options {
            version: protocol.unwrap_or_default().into(),
            ..Default::default()
        },
    )?;
    let trace_packetlines = std::env::var_os(
        gix::config::tree::Gitoxide::TRACE_PACKET
            .environment_override()
            .expect("set"),
    )
    .is_some();

    progress.info(format!("Connecting to {url:?}"));
    let agent = protocol::agent(gix::env::agent());

View on GitHub (pinned to e73179060b)