Conversation
| except RepositoryError: | ||
| repository.execute(["cherry-pick", "--abort"]) | ||
| raise |
There was a problem hiding this comment.
Bug: The error handler for a failed git cherry-pick unconditionally calls cherry-pick --abort, which can fail and mask the original error if no cherry-pick was in progress.
Severity: MEDIUM
Suggested Fix
Before calling repository.execute(["cherry-pick", "--abort"]), check if a cherry-pick operation is actually in progress. This can be done by verifying the existence of the .git/CHERRY_PICK_HEAD file, for example: if repository.has_git_file("CHERRY_PICK_HEAD"): repository.execute(["cherry-pick", "--abort"]). This aligns with the established defensive pattern used for rebase and merge aborts in the codebase.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: weblate/addons/git.py#L221-L223
Potential issue: The new error handling in the `squash_author` method calls
`repository.execute(["cherry-pick", "--abort"])` within an `except RepositoryError`
block. However, if the initial `cherry-pick` fails for reasons that do not leave the
repository in a cherry-pick state (e.g., an invalid commit reference), the `cherry-pick
--abort` command will also fail. This second failure raises a new `RepositoryError`,
masking the original, more informative error. This behavior is inconsistent with
existing patterns for `rebase --abort` and `merge --abort` in the codebase, which check
the repository state before attempting to abort. The same issue exists in a second
`cherry-pick` operation in the same method.
Did we get this right? 👍 / 👎 to inform future reviews.
|
Superseeded by #18337 |
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (40.00%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fixes WEBLATE-37ZV.
The issue was that: Cherry-pick fails due to merge conflicts, and the custom merge driver's immediate exit on
WEBLATE_MERGE_SKIPcausesRepositoryErrorto be raised.This pull request addresses the issue by:
git cherry-pick --abortis executed to clean up the repository state.RepositoryErroris then re-raised.This fix was generated by Seer in Sentry, triggered by Michal Čihař. 👁️ Run ID: 857074
Not quite right? Click here to continue debugging with Seer.