GitoxideLabs/gitoxide · error · anyhow::Error

JSON output isn't implemented yet

Error message

JSON output isn't implemented yet

What it means

The `exclude query` command checks which paths are excluded/ignored, but only the human output format is implemented. Requesting JSON output throws this error because JSON serialization of exclude query results does not exist yet.

Solutions

  1. Use the default human format (omit the format flag or pass `human`)
  2. Parse the human output if automation is required (fragile)
  3. Implement or request JSON support for the exclude subcommand

Example fix

// before
exclude::query(repo, query::Options { format: OutputFormat::Json, .. })?;
// after
exclude::query(repo, query::Options { format: OutputFormat::Human, .. })?;
Defensive patterns

Strategy: validation

Validate before calling

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

Try / catch

match exclude::query(repo, options) {
    Err(e) if e.to_string().contains("JSON output") => {
        exclude::query(repo, options_with_human_format)?
    }
    other => other?,
}

Prevention

When it happens

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

Common situations: CI or tooling that wants machine-readable ignore-check results; developers copying `--format json` from subcommands that do support it.

Related errors


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

Appendix: source

Thrown at gitoxide-core/src/repository/exclude.rs:34

        pub show_ignore_patterns: bool,
        pub statistics: bool,
    }
}

pub fn query(
    repo: gix::Repository,
    input: PathsOrPatterns,
    mut out: impl io::Write,
    mut err: impl io::Write,
    query::Options {
        overrides,
        format,
        show_ignore_patterns,
        statistics,
    }: query::Options,
) -> anyhow::Result<()> {
    if format != OutputFormat::Human {
        bail!("JSON output isn't implemented yet");
    }

    let index = repo.index()?;
    let mut cache = repo.excludes(
        &index,
        Some(gix::ignore::Search::from_overrides(
            overrides,
            repo.ignore_pattern_parser()?,
        )),
        Default::default(),
    )?;

    let paths: Box<dyn Iterator<Item = gix::bstr::BString>> = match input {
        PathsOrPatterns::Paths(paths) => paths,
        PathsOrPatterns::Patterns(paths) => Box::new(paths.into_iter()),
    };
    for path in paths {
        let mode = gix::path::from_bstr(Cow::Borrowed(path.as_ref()))

View on GitHub (pinned to e73179060b)