Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/+branchstatus-merging.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `MERGING` to `infrahub_sdk.branch.BranchStatus` to match the server-side enum (added in Infrahub 1.9.3). Without this, `client.branch.all()` raised `ValidationError` when any branch was returned with `status="MERGING"`, which could strand the task worker in a crashloop if a merge task died mid-flight and left a branch in that state.
1 change: 1 addition & 0 deletions infrahub_sdk/branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class BranchStatus(str, Enum):
NEED_REBASE = "NEED_REBASE"
NEED_UPGRADE_REBASE = "NEED_UPGRADE_REBASE"
DELETING = "DELETING"
MERGING = "MERGING"
MERGED = "MERGED"


Expand Down
20 changes: 20 additions & 0 deletions tests/unit/sdk/test_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from infrahub_sdk.branch import (
BranchData,
BranchStatus,
InfrahubBranchManager,
InfrahubBranchManagerSync,
)
Expand Down Expand Up @@ -38,6 +39,25 @@ def test_validate_method_signature(method: str) -> None:
assert async_sig.return_annotation == sync_sig.return_annotation


@pytest.mark.parametrize(
"status_value",
["OPEN", "NEED_REBASE", "NEED_UPGRADE_REBASE", "DELETING", "MERGING", "MERGED"],
)
def test_branch_data_accepts_all_server_statuses(status_value: str) -> None:
Comment thread
PhillSimonds marked this conversation as resolved.
Outdated
branch = BranchData.model_validate(
{
"id": "01J0",
"name": "test",
"sync_with_git": False,
"is_default": False,
"has_schema_changes": False,
"status": status_value,
"branched_from": "2026-01-01T00:00:00Z",
}
)
assert branch.status is BranchStatus(status_value)


@pytest.mark.parametrize("client_type", client_types)
async def test_get_branches(clients: BothClients, mock_branches_list_query: HTTPXMock, client_type: str) -> None:
if client_type == "standard":
Expand Down
Loading