{"record":{"id":"5f4985569dd88467","repo":"GitoxideLabs/gitoxide","slug":"cannot-find-character-that-we-didn-t-search-for","errorCode":null,"errorMessage":"cannot find character that we didn't search for","messagePattern":"cannot find character that we didn't search for","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-quote/src/ansi_c.rs","lineNumber":132,"sourceCode":"                                    .read_exact(&mut buf[1..])\n                                    .expect(\"impossible to fail as numbers match\");\n                                let byte = gix_utils::btoi::to_unsigned_with_radix(&buf, 8).or_raise(|| {\n                                    ValidationError::new_with_input(\"Invalid octal escape value\", original)\n                                })?;\n                                out.push(byte);\n                                input = &input[2..];\n                                consumed += 2;\n                            }\n                            _ => {\n                                return Err(ValidationError::new_with_input(\n                                    format!(\"Invalid escaped value {next}\"),\n                                    original,\n                                )\n                                .raise());\n                            }\n                        }\n                    }\n                    _ => unreachable!(\"cannot find character that we didn't search for\"),\n                }\n            }\n            None => {\n                return Err(\n                    ValidationError::new_with_input(\"Missing closing quote in quoted string\", original).raise(),\n                );\n            }\n        }\n    }\n    Ok((out.into(), consumed))\n}\n","sourceCodeStart":114,"sourceCodeEnd":144,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-quote/src/ansi_c.rs#L114-L144","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn looks_like_ansi_c_quoted(s: &[u8]) -> bool {\n    // well-formed: starts with '\"', escapes are paired, ends with unescaped '\"'\n    s.starts_with(b\"\\\"\") && s.ends_with(b\"\\\"\") && (s.len() < 2 || s[s.len()-2] != b'\\\\')\n}","typeGuard":"fn unquote_or_none(s: &[u8]) -> Option<std::borrow::Cow<'_, gix_hash::bstr::BStr>> {\n    if looks_like_ansi_c_quoted(s) { gix_quote::undo(s).ok() } else { Some(std::borrow::Cow::Borrowed(s.as_bstr())) }\n}","tryCatchPattern":"std::panic::catch_unwind(|| gix_quote::undo(quoted))\n    .ok()\n    .map(|r| r.ok())\n    .unwrap_or_else(|| Some(std::borrow::Cow::Borrowed(quoted.as_bstr()))) // fallback: treat as unquoted","preventionTips":["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"],"tags":["rust","panic","quoting","parsing"],"backgroundTag":"internal-invariant-violation","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}