{"record":{"id":"b653560c029083f9","repo":"gitbutlerapp/gitbutler","slug":"object-for-prefix-exists","errorCode":null,"errorMessage":"object for prefix exists","messagePattern":"object for prefix exists","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-debug/src/command/graph.rs","lineNumber":68,"sourceCode":"        .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        worktree_tips: vec![],\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            opts,\n        ),\n        Some(ref_name) => {\n            let mut reference = repo.find_reference(ref_name)?;\n            let id = reference.peel_to_id()?;\n            but_graph::Graph::from_commit_traversal(","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/2497b8007aa4a1922dae9a805b32ffe5b5037785/crates/but-debug/src/command/graph.rs#L50-L86","documentation":"Panic in 'but debug graph' when a --limit-extension value parses as valid hex but repo.objects.lookup_prefix finds no object whose id starts with that prefix (returns Ok(None)). The command assumes every well-formed prefix resolves locally and expects an object unconditionally; a matching-but-ambiguous prefix instead panics on the neighboring 'the prefix is unambiguous' expect.","triggerScenarios":"Passing an abbreviated hash from a different clone or repository; a commit that exists only on an unfetched remote; an object pruned by garbage collection; a valid-hex typo that matches nothing in the ODB.","commonSituations":"Copying short SHAs from a PR web page into a clone that never fetched that ref; shallow or partial clones missing the commit; prefix computed against a SHA-256 repo while the local repo is SHA-1.","solutions":["Verify the prefix resolves locally: 'git cat-file -t <prefix>' or 'git rev-parse --verify <prefix>^0'","Fetch the missing history first ('git fetch --all' or fetch the specific ref) and re-run","Use the full 40-char id to rule out typos and ambiguity","Maintainer: convert the unwrap/expect chain into an error naming the prefix"],"exampleFix":"// before\nrepo.objects.lookup_prefix(prefix, None).unwrap().expect(\"object for prefix exists\")\n\n// after\nlet Some(id) = repo.objects.lookup_prefix(prefix, None).map_err(anyhow::Error::from)? else {\n    anyhow::bail!(\"no object in this repository starts with prefix {short_hash}\");\n};","handlingStrategy":"validation","validationCode":"// Confirm the prefix resolves before invoking the debug graph\nlet output = std::process::Command::new(\"git\")\n    .args([\"cat-file\", \"-t\", short_hash])\n    .output()?;\nif !output.status.success() {\n    anyhow::bail!(\"no object '{short_hash}' in this clone; git fetch first\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fetch all remotes before debugging a SHA that came from a web page or another clone","Prefer full 40-char ids in scripts to avoid ambiguity and typo-misses","Remember the sibling expect: a too-short ambiguous prefix panics with 'the prefix is unambiguous'"],"tags":["rust","panic","git","object-database","prefix","cli"],"backgroundTag":"unknown-revision","analyzedSha":"2497b8007aa4a1922dae9a805b32ffe5b5037785","analyzedAt":"2026-08-17T00:30:25.648Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}