GitoxideLabs/gitoxide · error · anyhow::Error

JSON output isn't supported

Error message

JSON output isn't supported

What it means

The `gix tag list` command only supports human-readable output. `gitoxide_core::repository::tag::list` explicitly rejects any `OutputFormat` other than `OutputFormat::Human` with `anyhow::bail!` before enumerating references, because no JSON serialization is implemented for tags. The check happens first so no work is done for an unsupported format.

Solutions

  1. Use `OutputFormat::Human` (or omit the format flag) when listing tags.
  2. Parse the human output in your script if you need structured data, e.g. splitting on whitespace/newlines.
  3. Use `repo.references()?.tags()` via the `gix` library API directly and serialize the results yourself.
  4. Check `gix`/gitoxide-core release notes for when JSON support for `tag list` lands.

Example fix

// before
core::repository::tag::list(repo, &mut out, OutputFormat::Json)?;
// after
let tags: Vec<_> = repo.references()?.tags()?.collect::<Result<_, _>>()?;
for r in tags { writeln!(out, "{}", r.name().as_bstr())?; }
Defensive patterns

Strategy: validation

Validate before calling

if format != OutputFormat::Human { // fall back or error before calling list }
let format = if supports_json_tag_list { requested } else { OutputFormat::Human };

Type guard

fn is_human(f: OutputFormat) -> bool { matches!(f, OutputFormat::Human) }

Try / catch

match tag::list(&repo, &mut out, format) { Err(e) if e.to_string().contains("JSON output isn't supported") => tag::list(&repo, &mut out, OutputFormat::Human), other => other }

Prevention

When it happens

Trigger: Calling `tag::list(repo, out, OutputFormat::Json)` (or any non-Human variant) directly, or running a CLI invocation like `gix tag list --format json`, since the function immediately bails on non-Human formats.

Common situations: Developers scripting gitoxide CLI output expecting machine-readable JSON like other subcommands provide; tooling that uniformly passes a JSON format flag across many subcommands; callers upgrading gitoxide and assuming tag listing gained JSON support.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at gitoxide-core/src/repository/tag.rs:48

        let parts = version
            .chunk_by(|a, b| a.is_ascii_digit() == b.is_ascii_digit())
            .map(|part| {
                if let Ok(part) = part.to_str() {
                    part.parse::<usize>()
                        .map_or_else(|_| VersionPart::String(part.into()), VersionPart::Number)
                } else {
                    VersionPart::String(part.into())
                }
            })
            .collect();

        Self { parts }
    }
}

pub fn list(repo: gix::Repository, out: &mut dyn std::io::Write, format: OutputFormat) -> anyhow::Result<()> {
    if format != OutputFormat::Human {
        anyhow::bail!("JSON output isn't supported");
    }

    let platform = repo.references()?;

    let mut tags: Vec<_> = platform
        .tags()?
        .flatten()
        .map(|mut reference| {
            let tag = reference.peel_to_tag();
            let tag_ref = tag.as_ref().map(gix::Tag::decode);

            // `name` is the name of the file in `refs/tags/`.
            // This applies to both lightweight and annotated tags.
            let name = reference.name().shorten();
            let mut fields = Vec::new();
            let version = Version::parse(name);
            match tag_ref {
                Ok(Ok(tag_ref)) => {

View on GitHub (pinned to e73179060b)