reset proposed change status on unexpected merge failure#9164
Merged
Conversation
gmazoyer
reviewed
May 7, 2026
Comment on lines
+229
to
+242
| except BaseException as exc: | ||
| await _proposed_change_transition_state( | ||
| proposed_change=proposed_change, | ||
| state=ProposedChangeState.OPEN, | ||
| database=db, | ||
| user_id=context.account.account_id, | ||
| ) | ||
| return Failed(message=f"Merge failure when trying to merge {exc.message}") | ||
| if isinstance(exc, MergeFailedError): | ||
| return Failed(message=f"Merge failure when trying to merge {exc.message}") | ||
| if isinstance(exc, Exception): | ||
| log.exception("Unexpected failure during proposed change merge") | ||
| return Failed(message=f"Merge failure when trying to merge {source_branch.name}: {exc}") | ||
| # propagate a BaseException | ||
| raise |
Contributor
There was a problem hiding this comment.
Could we rewrite this using a try/except/finally block? I'm thinking about something like:
merge_succeeded = False
try:
await merge_branch(...)
merge_succeeded = True
except MergeFailedError as exc:
return Failed(message=f"Merge failure when trying to merge {exc.message}")
except Exception as exc:
log.exception("Unexpected failure during proposed change merge")
return Failed(message=f"Merge failure when trying to merge {source_branch.name}: {exc}")
finally:
if not merge_succeeded:
await _proposed_change_transition_state(...)I think that it would be easier to read.
Also the error message that would be displayed by MergeFailedError will be awkward because MergeFailedError will look lke Failed to merge branch '{branch_name}'. so we would read "Merge failure when trying to merge Failed to merge branch '{branch_name}'"
Contributor
Author
There was a problem hiding this comment.
great suggestion. applied all
gmazoyer
approved these changes
May 11, 2026
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.
IFC-2564
broaden the exception caught in
merge_proposed_changeto ensure that the merging Proposed Change's state is always reset to OPEN when a merge fails