fix(sidecar): re-register a missing origin remote instead of crashing on attach - #52
Merged
Merged
Conversation
… on attach A prior crashed boot can leave the vault dir as a real git repo (Repo.init persisted) but without the origin remote registered (create_remote/fetch never completed). On the next boot attach() hit `self._repo.remotes.origin.fetch()` and GitPython raised `AttributeError: 'IterableList' object has no attribute 'origin'`, crash-looping the pod. Look origin up by name via a defensive `_origin()` helper; if it is None re-create the remote and fetch, so attach() converges instead of crashing. Also use the same lookup in the init_adopted path. Verified: 14 tests pass (including the new test_attach_readds_origin_when_missing which reproduces the crash), ruff + mypy clean.
A bare Repo.init leaves the repo on the git default branch (often master), so after re-registering a missing origin we must check out the tracked branch (main) to converge. Fixes the CI failure where the re-add-origin attach left the checkout on master.
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.
fix(sidecar): re-register a missing origin remote instead of crashing on attach
A prior crashed boot can leave the vault dir as a real git repo (Repo.init
persisted) but without the origin remote registered (create_remote/fetch
never completed). On the next boot attach() hit
self._repo.remotes.origin.fetch()and GitPython raisedAttributeError: 'IterableList' object has no attribute 'origin',crash-looping the pod.
Look origin up by name via a defensive
_origin()helper; if it is Nonere-create the remote and fetch, so attach() converges instead of crashing.
Also use the same lookup in the init_adopted path.
Verified: 14 tests pass (including the new
test_attach_readds_origin_when_missing which reproduces the crash), ruff +
mypy clean.