GitoxideLabs/gitoxide · error · anyhow::Error

JSON output isn't yet supported for fetching.

Error message

JSON output isn't yet supported for fetching.

What it means

The `fetch` command reports fetch progress/results in human-readable form only; JSON output for fetching has not been implemented. Passing any non-Human OutputFormat throws this error before any network work starts.

Solutions

  1. Use the default human format (omit `--format` or pass `human`)
  2. Parse human output for automation (fragile)
  3. Implement or request JSON support for fetch

Example fix

// before
fetch(repo, remote, ref_specs, dry_run, OutputFormat::Json, progress)?;
// after
fetch(repo, remote, ref_specs, dry_run, OutputFormat::Human, progress)?;
Defensive patterns

Strategy: validation

Validate before calling

if format != OutputFormat::Human {
    eprintln!("fetch only supports human output");
    format = OutputFormat::Human;
}

Try / catch

match fetch(repo, remote, ref_specs, dry_run, format, progress) {
    Err(e) if e.to_string().contains("JSON output") => {
        fetch(repo, remote, ref_specs, dry_run, OutputFormat::Human, progress)?
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling `fetch` in gitoxide-core/src/repository/fetch.rs with `format != OutputFormat::Human`, e.g. `gix fetch --format json origin`.

Common situations: Automation wrapping fetch output in JSON; users copying the format flag from subcommands that support JSON.

Related errors


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

Appendix: source

Thrown at gitoxide-core/src/repository/fetch.rs:56

        mut out: impl std::io::Write,
        err: impl std::io::Write,
        Options {
            format,
            dry_run,
            remote,
            handshake_info,
            negotiation_info,
            open_negotiation_graph,
            shallow,
            ref_specs,
        }: Options,
    ) -> anyhow::Result<()>
    where
        P: gix::NestedProgress,
        P::SubProgress: 'static,
    {
        if format != OutputFormat::Human {
            bail!("JSON output isn't yet supported for fetching.");
        }

        let mut remote = crate::repository::remote::by_name_or_url(&repo, remote.as_deref())?;
        if !ref_specs.is_empty() {
            remote.replace_refspecs(ref_specs.iter(), gix::remote::Direction::Fetch)?;
            remote = remote.with_fetch_tags(gix::remote::fetch::Tags::None);
        }
        let res: gix::remote::fetch::Outcome = remote
            .connect(gix::remote::Direction::Fetch)?
            .prepare_fetch(&mut progress, Default::default())?
            .with_dry_run(dry_run)
            .with_shallow(shallow)
            .receive(&mut progress, &gix::interrupt::IS_INTERRUPTED)?;

        if handshake_info {
            writeln!(out, "Handshake Information")?;
            writeln!(out, "\t{:?}", res.handshake)?;
        }

View on GitHub (pinned to e73179060b)