GitoxideLabs/gitoxide · error

JSON output isn't implemented yet

Error message

JSON output isn't implemented yet

What it means

The `attributes query` command only implements human-readable output; requesting any other OutputFormat (JSON) bails before executing the query. JSON serialization for attribute queries has not been implemented yet.

Solutions

  1. Use the default human output format and parse it
  2. Call the gix library attributes API directly and serialize results yourself
  3. Track or file an upstream issue for JSON support in attribute queries

Example fix

// before
let opts = Options { format: OutputFormat::Json, statistics: None };
attributes::query(repo, input, out, err, opts)?;
// after
let opts = Options { format: OutputFormat::Human, statistics: None };
attributes::query(repo, input, out, err, opts)?;
Defensive patterns

Strategy: validation

Validate before calling

if format != OutputFormat::Human {
    eprintln!("attributes query: JSON not implemented; using Human");
    format = OutputFormat::Human;
}

Try / catch

match attributes::query(repo, input, out, err, opts) {
    Err(e) if e.to_string().contains("JSON output isn't implemented") => {
        // fall back to human output and parse text
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling `repository::attributes::query` with `format != OutputFormat::Human`, e.g. the CLI `ein tools attributes ... --format json` invocation.

Common situations: Tooling that uniformly requests JSON across gix subcommands; scripts parsing attribute query results as JSON.

Related errors


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

Appendix: source

Thrown at gitoxide-core/src/repository/attributes/query.rs:32

    use gix::bstr::BStr;

    use crate::{
        OutputFormat, is_dir_to_mode,
        repository::{
            PathsOrPatterns,
            attributes::query::{Options, attributes_cache},
        },
    };

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

        let (mut cache, index) = attributes_cache(&repo)?;
        let mut matches = cache.attribute_matches();

        match input {
            PathsOrPatterns::Paths(paths) => {
                for path in paths {
                    let mode = gix::path::from_bstr(Cow::Borrowed(path.as_ref()))
                        .metadata()
                        .ok()
                        .map(|m| is_dir_to_mode(m.is_dir()));

                    let entry = cache.at_entry(&path, mode)?;
                    if !entry.matching_attributes(&mut matches) {
                        continue;
                    }
                    print_match(&matches, path.as_ref(), &mut out)?;

View on GitHub (pinned to e73179060b)