{"record":{"id":"2cb13d8540aeec0b","repo":"GitoxideLabs/gitoxide","slug":"expected-exactly-one-hexadecimal-commit-id","errorCode":null,"errorMessage":"expected exactly one hexadecimal commit ID","messagePattern":"expected exactly one hexadecimal commit ID","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/lib.rs","lineNumber":7017,"sourceCode":"                _ => None,\n            };\n            selected.map_or(CommandMenuInput::Handled, |id| {\n                CommandMenuInput::Submit(\n                    commands\n                        .iter()\n                        .find(|command| command.id == id)\n                        .expect(\"a submitted command came from the current catalog\")\n                        .action\n                        .clone(),\n                )\n            })\n        }\n    }\n}\n\nfn resolve_pasted_commit(repository: &gix::Repository, pasted: &str) -> Result<gix::ObjectId> {\n    let hash = pasted.trim();\n    anyhow::ensure!(\n        !hash.is_empty() && hash.bytes().all(|byte| byte.is_ascii_hexdigit()),\n        \"expected exactly one hexadecimal commit ID\"\n    );\n    let object = repository\n        .rev_parse(hash.as_bytes().as_bstr())\n        .context(\"could not resolve pasted commit ID\")?\n        .single()\n        .context(\"pasted commit ID is ambiguous\")?\n        .object()\n        .context(\"could not read pasted object\")?;\n    anyhow::ensure!(\n        object.kind == gix::object::Kind::Commit,\n        \"pasted object is not a commit\"\n    );\n    Ok(object.id)\n}\n\nfn diagnostic_key(character: char) -> KeyEvent {","sourceCodeStart":6999,"sourceCodeEnd":7035,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/lib.rs#L6999-L7035","documentation":"`resolve_pasted_commit` validates that a pasted string is a non-empty, pure ASCII-hexadecimal token before resolving it against the repository with `rev_parse`. The `anyhow::ensure!` fires when the pasted text is empty or contains any non-hex character, since only a full hexadecimal commit ID is accepted in this UI path.","triggerScenarios":"Pasting into the interactive commit-pick flow a string that is empty, whitespace-only after trim, contains prefixes like `HEAD~1`, branch names, short refs, or any non-hex characters (gix-tix/src/lib.rs:7017).","commonSituations":"Copying `git log`-style lines that include `commit <sha>` prefixes or decorations; pasting symbolic names like `main` or `origin/main`; trailing punctuation or whitespace from a terminal; pasting a full OID with typos.","solutions":["Paste only the raw hexadecimal commit ID (40 or 64 hex chars depending on the repo hash).","Strip decorations/prefixes: copy just the OID, e.g. via `git rev-parse <name>` first.","If you need to accept symbolic names or short hashes, extend validation in `resolve_pasted_commit` to try `rev_parse` with gix's built-in prefix handling instead of requiring full hex.","Trim surrounding whitespace/newlines before passing the string (the code already trims, but the clipboard content must still be pure hex)."],"exampleFix":"// before\nlet pasted = \"commit 1a2b3c4...\"; // copied from git log\nresolve_pasted_commit(&repo, pasted)?;\n// after\nlet pasted = pasted.split_whitespace().last().expect(\"token from log line\");\nresolve_pasted_commit(&repo, pasted)?;","handlingStrategy":"validation","validationCode":"fn is_pasted_valid(pasted: &str) -> bool {\n    let h = pasted.trim();\n    !h.is_empty() && h.bytes().all(|b| b.is_ascii_hexdigit())\n}","typeGuard":null,"tryCatchPattern":"match resolve_pasted_commit(&repo, pasted) {\n    Err(e) if e.to_string().contains(\"expected exactly one hexadecimal commit ID\") => {\n        eprintln!(\"Paste a raw hexadecimal OID, not a branch name or decorated line\");\n    }\n    res => res?,\n}","preventionTips":["Copy only the bare OID column from `git log --format=%H`","Resolve symbolic names with `git rev-parse <name>^{commit}` before pasting","Trim clipboard content and strip `commit ` prefixes and decorations","For scripting, prefer rev-parse of a ref over pasting IDs"],"tags":["validation","input-format","hex","cli"],"backgroundTag":"invalid-argument-format","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"}