Hmbown/CodeWhale · error
Cannot safely inspect Git review configuration
Error message
Cannot safely inspect Git review configuration
What it means
review_command runs `git config` with -z to list review filters and only trusts the result when the exit code and output shape are exactly what it expects (success with NUL-terminated output, or exit 1 with empty output meaning no filters). Any other combination is treated as an unparseable git state and fails closed rather than allowing a misconfigured review flow.
Solutions
- Run `git config --list` yourself to find and fix the parse error in a config file
- Check that `git` on PATH is the real git binary (not a wrapper) and works with --null/-z output
- Unset GIT_PAGER/core.pager or environment overrides that could alter output
- Inspect `git config -z --get-regexp <filter>` directly and fix the offending config key
Example fix
// before: broken config makes output non-NUL-terminated // after git config --global --unset broken.key # or fix .gitconfig syntax // then re-run the review command
Defensive patterns
Strategy: try-catch
Validate before calling
let out = Command::new("git").args(["config","-z","--get-regexp","filter.*"]).output()?;
let ok = out.status.success() || (out.status.code() == Some(1) && out.stdout.is_empty()); Try / catch
match result {
Err(e) if e.to_string().contains("Cannot safely inspect Git review configuration") => {
// inspect git config manually, fix corrupt config, retry
}
other => other?,
} Prevention
- Keep git config files syntactically valid; validate after edits
- Do not alias or wrap `git` on PATH in ways that change output
- Disable pagers/GIT_PAGER for scripted git calls
When it happens
Trigger: `git config --get-regexp` (or equivalent filter listing) exits nonzero with visible output, exits with an unexpected code, or emits stdout that does not end in a NUL byte.
Common situations: Broken or unusual git installations, aliases/wrappers replacing git, a git config file with corrupt syntax, security tools intercepting git, or a locale/pager injecting output.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- a CNB access token is not configured in the Codewhale…
- A full Git history is required to establish the PR merge…
- account_agent_model_unconfigured
- active profile is missing or malformed
- advisor model ` ` resolved only to a custom provider kind…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/69e55def9300fce4.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/dependencies.rs:445
.env("GIT_PAGER", "");
Ok(command)
};
let output = base()?
.args([
"config",
"--null",
"--name-only",
"--get-regexp",
r"^filter\..*\.(clean|process|required)$",
])
.output()
.context("Failed to inspect Git review filters")?;
let no_filters =
output.status.code() == Some(1) && output.stdout.is_empty() && output.stderr.is_empty();
if (!output.status.success() && !no_filters)
|| (!output.stdout.is_empty() && !output.stdout.ends_with(&[0]))
{
bail!("Cannot safely inspect Git review configuration");
}
let mut filters = std::collections::BTreeSet::new();
for key in output
.stdout
.split(|byte| *byte == 0)
.filter(|key| !key.is_empty())
{
let key =
std::str::from_utf8(key).context("Git review filter name is not valid UTF-8")?;
let (driver, _) = key
.rsplit_once('.')
.context("Invalid Git review filter key")?;
filters.insert(driver);
}
let mut command = base()?;
let mut count = 2;
for driver in filters {
for (suffix, value) in [("clean", ""), ("process", ""), ("required", "false")] {View on GitHub (pinned to 73e0f67d83)