Skip to content

reset proposed change status on unexpected merge failure#9164

Merged
ajtmccarty merged 3 commits into
stablefrom
ajtm-05062026-reset-pc-on-merge-fail
May 11, 2026
Merged

reset proposed change status on unexpected merge failure#9164
ajtmccarty merged 3 commits into
stablefrom
ajtm-05062026-reset-pc-on-merge-fail

Conversation

@ajtmccarty
Copy link
Copy Markdown
Contributor

IFC-2564

broaden the exception caught in merge_proposed_change to ensure that the merging Proposed Change's state is always reset to OPEN when a merge fails

@github-actions github-actions Bot added the group/backend Issue related to the backend (API Server, Git Agent) label May 7, 2026
@ajtmccarty ajtmccarty marked this pull request as ready for review May 7, 2026 00:59
@ajtmccarty ajtmccarty requested a review from a team as a code owner May 7, 2026 00:59
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 7, 2026

Merging this PR will not alter performance

✅ 12 untouched benchmarks


Comparing ajtm-05062026-reset-pc-on-merge-fail (b2a7a3b) with stable (045500f)

Open in CodSpeed

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
Copy link
Copy Markdown
Contributor

@gmazoyer gmazoyer May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}'"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great suggestion. applied all

@ajtmccarty ajtmccarty requested a review from gmazoyer May 11, 2026 14:58
@ajtmccarty ajtmccarty merged commit d56017f into stable May 11, 2026
89 of 90 checks passed
@ajtmccarty ajtmccarty deleted the ajtm-05062026-reset-pc-on-merge-fail branch May 11, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

group/backend Issue related to the backend (API Server, Git Agent)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants