fix: detect and recover from corrupted git clones in plugin cache#14
Merged
Conversation
When a plugin git clone failed or was interrupted, the cache directory was left in a broken state (temp pack file, no refs). Subsequent installs skipped re-cloning because the directory existed, resulting in zero skills being symlinked. - Add isRepoHealthy() using git.PlainOpen + repo.Head() to validate cache integrity (handles packed-refs and detached HEAD correctly) - Add post-clone validation in cloneGitSource to detect incomplete clones - Clean up cache on clone failure to prevent broken state persisting - Handle os.RemoveAll error when evicting corrupted cache
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
When a remote plugin git clone failed or was interrupted, the cache directory was left in a broken state (temp pack file, no refs, no working tree). Subsequent
plugin installcalls skipped re-cloning because the cache directory existed, sogenerateFallbackManifestcreatedplugin.jsonfrom marketplace metadata and the symlink step silently linked 0 skills.Changes
installer.go—materializePlugin: validate cache integrity before skipping clone. Usesgit.PlainOpen+repo.Head()to detect broken repos (handles packed-refs and detached HEAD correctly). Evicts corrupted cache with proper error handling.installer.go—isRepoHealthy: replaces the hand-rolledisValidGitRepo(which checked.git/refs/headsentries — broken for packed-refs repos).version.go—cloneGitSource: add post-clone validation (PlainOpen+Head()) to catch incomplete clones immediately. Clean up cache on any clone error to prevent broken state persisting.Test plan
go test ./...)go vetpasses