Skip to content

fix(crafter): handle invalid merge branch config during repo open#3032

Merged
migmartri merged 1 commit intochainloop-dev:mainfrom
migmartri:fix/crafter-invalid-merge-branch
Apr 14, 2026
Merged

fix(crafter): handle invalid merge branch config during repo open#3032
migmartri merged 1 commit intochainloop-dev:mainfrom
migmartri:fix/crafter-invalid-merge-branch

Conversation

@migmartri
Copy link
Copy Markdown
Member

@migmartri migmartri commented Apr 14, 2026

Summary

  • Upgrade go-git from v5.17.1 to v5.17.2
  • Gracefully handle branch config: invalid merge errors from go-git when opening a repository, not just when listing remotes. This is a protective measure to prevent the crafter from crashing on repos with invalid merge references in their git config, similar to the existing protection we already had for the remote-listing path
  • Extract isBranchInvalidMergeError helper to deduplicate the string-based error check

Closes #3031

@migmartri migmartri requested a review from jiparis April 14, 2026 15:07
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="pkg/attestation/crafter/crafter.go">

<violation number="1" location="pkg/attestation/crafter/crafter.go:340">
P2: When `repo.Remotes()` hits `branch config: invalid merge`, this now returns `nil` head commit instead of preserving the already-resolved commit metadata.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread pkg/attestation/crafter/crafter.go
@migmartri migmartri force-pushed the fix/crafter-invalid-merge-branch branch from 3f63151 to a734897 Compare April 14, 2026 15:15
Comment thread pkg/attestation/crafter/crafter.go
@migmartri migmartri force-pushed the fix/crafter-invalid-merge-branch branch from a734897 to ce07ac1 Compare April 14, 2026 15:19
Gracefully handle "branch config: invalid merge" errors from go-git
when opening a repository, similar to the existing protection for
remote listing. This prevents the crafter from crashing when the
local git config has an invalid merge reference.

Also upgrades go-git to v5.17.2.

Closes chainloop-dev#3031

Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
@migmartri migmartri force-pushed the fix/crafter-invalid-merge-branch branch from ce07ac1 to 52133f5 Compare April 14, 2026 15:21
@migmartri migmartri merged commit 6fcedb6 into chainloop-dev:main Apr 14, 2026
13 checks passed
@migmartri migmartri deleted the fix/crafter-invalid-merge-branch branch April 14, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

error getting git commit hash: opening repository: branch config: invalid merge

2 participants