Skip to content

Commit 23a55e2

Browse files
authored
Merge pull request #514 from opsmill/bkr-race-conditions-offset
Fixes race conditions offset
2 parents 6e43166 + 527c0a5 commit 23a55e2

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

changelog/+race-condition.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update offset in process_page() which was causing a race condition in rare case.

infrahub_sdk/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ async def filters(
790790
async def process_page(page_offset: int, page_number: int) -> tuple[dict, ProcessRelationsNode]:
791791
"""Process a single page of results."""
792792
query_data = await InfrahubNode(client=self, schema=schema, branch=branch).generate_query_data(
793-
offset=offset or page_offset,
793+
offset=page_offset if offset is None else offset,
794794
limit=limit or pagination_size,
795795
filters=filters,
796796
include=include,
@@ -1954,7 +1954,7 @@ def filters(
19541954
def process_page(page_offset: int, page_number: int) -> tuple[dict, ProcessRelationsNodeSync]:
19551955
"""Process a single page of results."""
19561956
query_data = InfrahubNodeSync(client=self, schema=schema, branch=branch).generate_query_data(
1957-
offset=offset or page_offset,
1957+
offset=page_offset if offset is None else offset,
19581958
limit=limit or pagination_size,
19591959
filters=filters,
19601960
include=include,

infrahub_sdk/node/node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from collections.abc import Iterable
4-
from copy import copy
4+
from copy import copy, deepcopy
55
from typing import TYPE_CHECKING, Any
66

77
from ..constants import InfrahubClientMode
@@ -397,7 +397,7 @@ def generate_query_data_init(
397397
"edges": {"node": {"id": None, "hfid": None, "display_label": None, "__typename": None}},
398398
}
399399

400-
data["@filters"] = filters or {}
400+
data["@filters"] = deepcopy(filters) if filters is not None else {}
401401

402402
if order:
403403
data["@filters"]["order"] = order

0 commit comments

Comments
 (0)