GitoxideLabs/gitoxide · error
Format for extension
Error message
Format for extension '{ext}' is unsupported What it means
`format_from_ext` supports only the extensions tar, gz, zip, and stream. Any other extension causes a bail naming the unsupported extension. This is a whitelist of explicitly implemented archive formats.
Solutions
- Rename the output to an exact supported extension: `.tar`, `.gz`, `.zip`, or `.stream`
- Use `.tar.gz` -> not supported; instead write to `.gz` (TarGz) per the implementation
- Add post-processing (e.g. pipe the tar output through zstd) outside of gix for other compressions
- Check `archive::Format` for the currently supported set before choosing a filename
Example fix
// before
let out = Path::new("release.tgz");
// after
let out = Path::new("release.gz"); // TarGz Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED: &[&str] = &["tar", "gz", "zip", "stream"];
let ext = path.extension().and_then(|e| e.to_str()).unwrap_or("");
anyhow::ensure!(SUPPORTED.contains(&ext), "extension '{ext}' unsupported; use one of {SUPPORTED:?}"); Try / catch
match format_from_ext(path) {
Err(e) if e.to_string().contains("is unsupported") => {
eprintln!("use .tar, .gz, .zip or .stream");
}
other => other?,
} Prevention
- Map user-friendly names (.tgz, .tar.gz) to supported extensions before calling archive
- Consult `archive::Format` for the implemented format list
- Handle other compressions (zstd, bz2) outside gix via post-processing
When it happens
Trigger: Calling `archive::stream` with an output file whose extension is anything outside {tar, gz, zip, stream}, e.g. `out.tgz`, `out.tar.zst`, `out.bz2`, `out.rar`.
Common situations: Users typing `.tgz` or `.tar.gz` expecting gzip support; requesting zstd/bzip2 compression not yet implemented; scripts defaulting to `.7z`.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Cannot derive archive format from a file without extension
- lines in ' ' could not be parsed
- Invalid pathspec - path must not be empty, not be excluded…
- : Validation failed with mismatches out of
- path does not name a file
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/a31a1589b01b140d.
Report an issue: GitHub.
Appendix: source
Thrown at gitoxide-core/src/repository/archive.rs:106
}
gix::object::Kind::Tree => (None, object.id),
gix::object::Kind::Tag => fetch_rev_info(object.peel_to_kind(gix::object::Kind::Commit)?)?,
gix::object::Kind::Blob => bail!("Cannot derive commit or tree from blob at {}", object.id),
})
}
fn format_from_ext(path: &Path) -> anyhow::Result<archive::Format> {
Ok(match path.extension().and_then(std::ffi::OsStr::to_str) {
None => bail!("Cannot derive archive format from a file without extension"),
Some("tar") => archive::Format::Tar,
Some("gz") => archive::Format::TarGz {
compression_level: None,
},
Some("zip") => archive::Format::Zip {
compression_level: None,
},
Some("stream") => archive::Format::InternalTransientNonPersistable,
Some(ext) => bail!("Format for extension '{ext}' is unsupported"),
})
}
View on GitHub (pinned to e73179060b)