Skip to content

Commit 9ab7bfb

Browse files
fatih-acarclaude
andcommitted
fix(branch): do not reopen merged branches when converting agnostic nodes
_get_other_active_branches in object_conversion returned MERGED and DELETING branches, which the caller then unconditionally set to NEED_REBASE — effectively reopening merged branches when converting an agnostic node with aware attributes. Filter them out using Branch.is_terminal. Refs #9103 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ec7ca5f commit 9ab7bfb

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

backend/infrahub/core/convert_object_type/object_conversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ async def get_unidirectional_rels_peers_ids(
9292

9393
async def _get_other_active_branches(db: InfrahubDatabase) -> list[Branch]:
9494
branches = await Branch.get_list(db=db)
95-
return [branch for branch in branches if not (branch.is_global or branch.is_default)]
95+
return [branch for branch in branches if not (branch.is_global or branch.is_default or branch.is_terminal)]
9696

9797

9898
def _has_pass_thru_aware_attributes(node_schema: NodeSchema, mapping: dict[str, ConversionFieldInput]) -> bool:

backend/tests/component/core/convert_object_type/test_convert_object_type.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@ async def test_agnostic_node_with_aware_attributes(
318318
branch_name = "branch_convert_type"
319319
_ = await create_branch(branch_name=branch_name, db=db)
320320

321+
merged_branch_name = "merged_branch_convert_type"
322+
merged_branch = await create_branch(branch_name=merged_branch_name, db=db)
323+
merged_branch.status = BranchStatus.MERGED
324+
await merged_branch.save(db=db)
325+
321326
mapping = {
322327
"name_agnostic": ConversionFieldInput(source_field="name_agnostic"),
323328
"age_aware": ConversionFieldInput(source_field="age_aware"),
@@ -359,3 +364,7 @@ async def test_agnostic_node_with_aware_attributes(
359364
assert main_branch.status == BranchStatus.OPEN.value
360365
global_branch = await Branch.get_by_name(name=GLOBAL_BRANCH_NAME, db=db)
361366
assert global_branch.status == BranchStatus.OPEN.value
367+
368+
# Merged branches are terminal/read-only and must not be reopened
369+
refreshed_merged = await Branch.get_by_name(name=merged_branch_name, db=db)
370+
assert refreshed_merged.status == BranchStatus.MERGED.value

changelog/9103.fixed.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stop object-type conversion of agnostic nodes with aware attributes from re-opening merged or deleting branches. The "needs rebase" status now only applies to non-terminal branches.

0 commit comments

Comments
 (0)