zed-industries/zed · error
Invalid status code: {byte}
Error message
Invalid status code: {byte} What it means
FileStatus::from_bytes parses the two-character XY codes of `git status --porcelain=v1` output. StatusCode::from_byte accepts M, T, A, D, R, C and space; any other byte in an X or Y position raises this error, printing the byte value so you can see what git actually emitted.
Source
Thrown at crates/git/src/status.rs:235
conflict: 0,
untracked: 0,
count: 1,
},
}
}
}
impl StatusCode {
fn from_byte(byte: u8) -> anyhow::Result<Self> {
match byte {
b'M' => Ok(StatusCode::Modified),
b'T' => Ok(StatusCode::TypeChanged),
b'A' => Ok(StatusCode::Added),
b'D' => Ok(StatusCode::Deleted),
b'R' => Ok(StatusCode::Renamed),
b'C' => Ok(StatusCode::Copied),
b' ' => Ok(StatusCode::Unmodified),
_ => anyhow::bail!("Invalid status code: {byte}"),
}
}
fn to_summary(self) -> TrackedSummary {
match self {
StatusCode::Modified | StatusCode::TypeChanged => TrackedSummary {
modified: 1,
..TrackedSummary::UNCHANGED
},
StatusCode::Added => TrackedSummary {
added: 1,
..TrackedSummary::UNCHANGED
},
StatusCode::Deleted => TrackedSummary {
deleted: 1,
..TrackedSummary::UNCHANGED
},
StatusCode::Renamed | StatusCode::Copied | StatusCode::Unmodified => {View on GitHub (pinned to f4178619ac)
Solutions
- Reproduce with the exact command (`git status --porcelain=v1 --untracked-files=all --no-renames -z --`) and inspect the XY bytes of each line.
- Remove aliases/wrappers (check `alias.status`, `core.pager`, GIT_* env) that could alter stdout.
- Pin or upgrade git to a version with standard porcelain v1 output.
- If standard git truly emits an undocumented byte, report it upstream with the raw line.
Defensive patterns
Strategy: try-catch
Try / catch
match stdout.parse::<GitStatus>() {
Err(e) if e.to_string().contains("Invalid status code") => {
// nonstandard porcelain output: capture raw output, check git version and aliases, report
}
other => other?,
} Prevention
- Pin a stock git binary; avoid aliases or wrappers that rewrite status output.
- Capture and parse status with exactly the flags the parser expects (--porcelain=v1 -z).
- Log the raw status bytes when parsing fails so the offending line is visible.
When it happens
Trigger: Parsing porcelain output whose XY codes contain an unexpected character: a wrapper or alias rewriting `git status` output, a git version emitting codes outside the documented set, or misaligned parsing after a preceding entry was mis-split (output captured without `-z` while the parser expects NUL delimiters, or vice versa).
Common situations: Machines with shell aliases/functions wrapping git status; unusual or very new git builds whose porcelain output differs; output captured with different flags than the parser assumes; embedded environments injecting banners into stdout.
Related errors
- Invalid unmerged status code: {byte}
- invalid cat-file header: {header_line}
- git status failed: {stderr}
- grammar directory '{}' already exists, but is not a git clon
- failed to run `git init` in directory '{}'
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/99b8e8d0af6c781b.
Report an issue: GitHub.