{"record":{"id":"e474edc4c7a25e88","repo":"gitbutlerapp/gitbutler","slug":"valid-hex-prefix","errorCode":null,"errorMessage":"valid hex prefix","messagePattern":"valid hex prefix","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-debug/src/command/graph.rs","lineNumber":64,"sourceCode":"\n    let extra_target = graph_args\n        .extra_target\n        .as_deref()\n        .map(|rev_spec| repo.rev_parse_single(rev_spec))\n        .transpose()?\n        .map(|id| id.detach());\n    let opts = but_graph::init::Options {\n        extra_target_commit_id: extra_target,\n        collect_tags: true,\n        hard_limit: graph_args.hard_limit,\n        commits_limit_hint: graph_args.limit.flatten(),\n        commits_limit_recharge_location: graph_args\n            .limit_extension\n            .iter()\n            .map(|short_hash| {\n                repo.objects\n                    .lookup_prefix(\n                        gix::hash::Prefix::from_hex(short_hash).expect(\"valid hex prefix\"),\n                        None,\n                    )\n                    .unwrap()\n                    .expect(\"object for prefix exists\")\n                    .expect(\"the prefix is unambiguous\")\n            })\n            .collect(),\n        dangerously_skip_postprocessing_for_debugging: graph_args.no_post,\n        worktrees: false,\n    };\n\n    let graph = match graph_args.ref_name.as_deref() {\n        None => but_graph::Graph::from_head(\n            &repo,\n            &meta,\n            but_core::ref_metadata::ProjectMeta::default(),\n            &mut setup::debug_db()?,\n            opts,","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-debug/src/command/graph.rs#L46-L82","documentation":"A panic (expect) in but-debug's graph command: each --limit-extension value is parsed with gix::hash::Prefix::from_hex(), and a value containing non-hex characters or a bad length aborts the process with 'valid hex prefix'. Debug-only code path, so input validation is deliberately terse.","triggerScenarios":"Running `but debug graph --limit-extension <value>` where <value> is not a hex string of 4..=hash-length hex chars — e.g. a branch name, a full ref, or a hash with a typo ('g' instead of 'f').","commonSituations":"Copy/pasting a branch or ref name where a short hash belongs; trailing whitespace or a 'refs/' prefix in the pasted value; SHA strings from other tools containing non-hex separators.","solutions":["Pass only hex characters (0-9a-f), e.g. --limit-extension 4c1f0ab.","Get a valid short hash from `git rev-parse --short <ref>` first.","Strip whitespace/ref prefixes before passing the value."],"exampleFix":"# before\nbut debug graph --limit-extension main\n\n# after\nbut debug graph --limit-extension $(git rev-parse --short main)","handlingStrategy":"validation","validationCode":"# shell: reject non-hex before invoking the CLI\nif ! [[ \"$EXT\" =~ ^[0-9a-fA-F]{4,64}$ ]]; then\n  echo \"--limit-extension must be 4-64 hex chars\" >&2; exit 2\nfi","typeGuard":"function isHexPrefix(s: string): boolean {\n  return /^[0-9a-f]{4,64}$/i.test(s);\n}","tryCatchPattern":null,"preventionTips":["Feed --limit-extension exclusively from `git rev-parse --short <ref>` output.","Trim whitespace and never pass ref names where a hash prefix is expected."],"tags":["rust","cli","debug-tooling","panic","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}