GitoxideLabs/gitoxide · error
cannot find character that we didn't search for
Error message
cannot find character that we didn't search for
What it means
An `unreachable!()` panic in `gix_quote::undo`, the public function that unquotes C-style/ANSI-C quoted strings. While stripping backslash escapes the code iterates over characters it previously searched for (quote or backslash); the panic fires if `undo` encounters a byte position whose character was not part of that search set, meaning the escape-scanning index and the character iteration got out of sync.
Solutions
- Upgrade gix-quote / gix to the latest version and retry
- Sanitize or pre-validate the quoted input: ensure escapes are well-formed pairs (`\\`, `\"`) before calling `undo`
- If the input comes from another tool, prefer obtaining the raw unquoted value from the source instead of undo-ing the quoted form
- Report the exact input bytes upstream as a gix-quote bug
Defensive patterns
Strategy: validation
Validate before calling
fn looks_like_ansi_c_quoted(s: &[u8]) -> bool {
// well-formed: starts with '"', escapes are paired, ends with unescaped '"'
s.starts_with(b"\"") && s.ends_with(b"\"") && (s.len() < 2 || s[s.len()-2] != b'\\')
} Type guard
fn unquote_or_none(s: &[u8]) -> Option<std::borrow::Cow<'_, gix_hash::bstr::BStr>> {
if looks_like_ansi_c_quoted(s) { gix_quote::undo(s).ok() } else { Some(std::borrow::Cow::Borrowed(s.as_bstr())) }
} Try / catch
std::panic::catch_unwind(|| gix_quote::undo(quoted))
.ok()
.map(|r| r.ok())
.unwrap_or_else(|| Some(std::borrow::Cow::Borrowed(quoted.as_bstr()))) // fallback: treat as unquoted Prevention
- Prefer raw values from APIs over undo-ing quoted CLI output when possible
- Validate quoting is well-formed (paired escapes, balanced quotes) before undo
- Keep gix-quote updated; undo scanner fixes ship as patch releases
- Handle non-quoted input directly instead of forcing it through undo
When it happens
Trigger: Calling `gix_quote::undo` on a byte string containing ANSI-C quoted content (e.g. a path from `git config --get` output or `core.quotePath`-style output) whose escape sequence layout hits an out-of-sync branch — e.g. a string ending in a lone backslash or a misplaced escape immediately before the closing quote; effectively a bug in gix-quote's undo scanner.
Common situations: Consuming output produced by other tools (git CLI, third-party writers) that emit slightly non-standard quoting, or using a gix-quote version with an incomplete escape-handling fix; users on standard git-produced quoted paths don't hit it.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- ' ' is not a valid configuration key
- Cannot use iter_v1() on index of type
- Cannot use iter_v2() on index of type
- BUG: tries to obtain object id from symbolic target
- BUG: expected peeled reference target but found symbolic one
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/5f4985569dd88467.
Report an issue: GitHub.
Appendix: source
Thrown at gix-quote/src/ansi_c.rs:132
.read_exact(&mut buf[1..])
.expect("impossible to fail as numbers match");
let byte = gix_utils::btoi::to_unsigned_with_radix(&buf, 8).or_raise(|| {
ValidationError::new_with_input("Invalid octal escape value", original)
})?;
out.push(byte);
input = &input[2..];
consumed += 2;
}
_ => {
return Err(ValidationError::new_with_input(
format!("Invalid escaped value {next}"),
original,
)
.raise());
}
}
}
_ => unreachable!("cannot find character that we didn't search for"),
}
}
None => {
return Err(
ValidationError::new_with_input("Missing closing quote in quoted string", original).raise(),
);
}
}
}
Ok((out.into(), consumed))
}
View on GitHub (pinned to e73179060b)