Fix nil-pointer panic in checkpoint parent-load error path#80
Merged
Conversation
In FirstParentChainStoppingAt, when object.GetCommit fails to load a first parent it returns a nil commit, but the error message dereferenced commit.ParentHashes[0] — a guaranteed nil-pointer panic (and the wrong hash even if it didn't crash). Use the parent hash we tried to load instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: bb21edce625a
pjbgf
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In
FirstParentChainStoppingAt(internal/planner/checkpoint.go):On error,
object.GetCommitreturns a nil commit, socommit.ParentHashes[0]is a guaranteed nil-pointer dereference panic — and even if it didn't panic it would print the wrong hash. Only reachable through the exported planner API, which is why it hadn't fired.Fix
Reference the
parenthash we just tried to load. The two siblingGetCommitsites in the same file already use the correct (input) hash in their messages, so this brings the error path in line.Tests
TestFirstParentChainStoppingAtMissingParentErrorsseeds a commit whose first parent is absent from the store and asserts the call returns an error naming the missing parent (rather than panicking).🤖 Generated with Claude Code
Note
Low Risk
Single-line error-path fix in planner checkpoint walking with a focused regression test; no behavior change on success paths.
Overview
Fixes a bug in
FirstParentChainStoppingAtwhere loading a missing first-parent commit could panic instead of returning an error.On
GetCommitfailure the code formatted the error withcommit.ParentHashes[0], but the failed call leavescommitnil. The message now uses theparenthash that was just requested, matching the other error paths in the same file.Adds
TestFirstParentChainStoppingAtMissingParentErrors, which seeds a tip whose first parent is absent from the store and checks the returned error names that parent (and does not panic).Reviewed by Cursor Bugbot for commit 43a0631. Configure here.