{"record":{"id":"cc7f6d4c75f8e36a","repo":"zed-industries/zed","slug":"invalid-hex-digit-at-byte-index-for-git-oid","errorCode":null,"errorMessage":"invalid hex digit at byte {index} for git oid","messagePattern":"invalid hex digit at byte (.+?) for git oid","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/git/src/git.rs","lineNumber":299,"sourceCode":"\nimpl FromStr for Oid {\n    type Err = anyhow::Error;\n\n    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {\n        let format = match s.len() {\n            1..=SHA1_HEX_LENGTH => OidFormat::Sha1,\n            SHA256_HEX_LENGTH => OidFormat::Sha256,\n            len => {\n                anyhow::bail!(\n                    \"invalid git oid hex length: expected 1..={SHA1_HEX_LENGTH} for SHA-1 or {SHA256_HEX_LENGTH} for SHA-256, got {len}\"\n                );\n            }\n        };\n\n        let mut bytes = [0u8; SHA256_BYTE_LENGTH];\n        for (index, byte) in s.bytes().enumerate() {\n            let digit = decode_hex_digit(byte)\n                .ok_or_else(|| anyhow::anyhow!(\"invalid hex digit at byte {index} for git oid\"))?;\n            if index % 2 == 0 {\n                bytes[index / 2] = digit << 4;\n            } else {\n                bytes[index / 2] |= digit;\n            }\n        }\n\n        Ok(Self { bytes, format })\n    }\n}\n\nfn decode_hex_digit(byte: u8) -> Option<u8> {\n    match byte {\n        b'0'..=b'9' => Some(byte - b'0'),\n        b'a'..=b'f' => Some(byte - b'a' + 10),\n        b'A'..=b'F' => Some(byte - b'A' + 10),\n        _ => None,\n    }","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/git/src/git.rs#L281-L317","documentation":"Oid::from_str found a non-hexadecimal character at byte {index} while decoding a git object id. The length check already passed (SHA-1 or SHA-256 sized), but byte-level decoding hit a character outside [0-9a-f], so the string is not a valid object id — usually a typo, truncated-with-garbage sha, or an oid contaminated with formatting characters.","triggerScenarios":"Thrown at crates/git/src/git.rs:299 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Strip whitespace, quotes, or 'origin/' style prefixes before parsing sha strings","Validate shas against ^[0-9a-fA-F]+$ at the boundary that produced them","Report the byte index to the user — it pinpoints where the garbage begins"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}