Skip to content

fix: add helpful error message for git repository issues#260

Merged
wu-sheng merged 1 commit intoapache:mainfrom
jhult:fix/git-repository-error-handling
Feb 11, 2026
Merged

fix: add helpful error message for git repository issues#260
wu-sheng merged 1 commit intoapache:mainfrom
jhult:fix/git-repository-error-handling

Conversation

@jhult
Copy link
Copy Markdown
Contributor

@jhult jhult commented Feb 11, 2026

Summary

  • Catch plumbing.ErrObjectNotFound error when go-git fails to read git objects during file iteration
  • Provide helpful diagnostic message suggesting git fsck to diagnose the issue
  • Suggest cleanup command (git prune && git gc --prune=now --aggressive) if dangling objects are found

Problem

When a git repository has dangling objects, go-git's tree.Files().ForEach() fails with ErrObjectNotFound, resulting in an unhelpful error message "object not found" that doesn't guide users to a solution.

Solution

Added error handling to catch ErrObjectNotFound specifically and provide actionable guidance to diagnose and fix the issue.

@jhult jhult force-pushed the fix/git-repository-error-handling branch from 32ef01e to 8b13818 Compare February 11, 2026 02:14
@wu-sheng wu-sheng requested review from Copilot and kezhenxu94 and removed request for Copilot February 11, 2026 11:51
@kezhenxu94
Copy link
Copy Markdown
Member

@jhult can you please fix the linting issue?

@jhult jhult force-pushed the fix/git-repository-error-handling branch from 71e39b8 to 0a219bf Compare February 11, 2026 15:00
@jhult
Copy link
Copy Markdown
Contributor Author

jhult commented Feb 11, 2026

@kezhenxu94, done.

@wu-sheng wu-sheng merged commit 7a3b6cc into apache:main Feb 11, 2026
1 check passed
@jhult jhult deleted the fix/git-repository-error-handling branch February 11, 2026 16:57
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.

3 participants