Skip to content

Commit c4f1b8a

Browse files
authored
fix batching bug in diff query (#6483)
* fix batching bug in diff query * add changelog
1 parent 4f60827 commit c4f1b8a

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

backend/infrahub/core/diff/query_parser.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,11 @@ def get_current_node_field_specifiers(self) -> NodeFieldSpecifierMap:
526526
return self._current_node_field_specifiers
527527

528528
def read_result(self, query_result: QueryResult) -> None:
529-
path = query_result.get_path(label="diff_path")
529+
try:
530+
path = query_result.get_path(label="diff_path")
531+
except ValueError:
532+
# the path was null, so nothing to read
533+
return
530534
database_path = DatabasePath.from_cypher_path(cypher_path=path)
531535
self._parse_path(database_path=database_path)
532536
self._current_node_field_specifiers = None

backend/infrahub/core/query/diff.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ def __init__(
201201
diff_rel_paths = [], item IN [penultimate_path, peer_path] |
202202
CASE WHEN item IS NULL THEN diff_rel_paths ELSE diff_rel_paths + [item] END
203203
) AS diff_rel_paths, has_more_data
204+
// ------------------------
205+
// make sure we still include has_more_data if diff_rel_paths is empty
206+
// ------------------------
207+
WITH CASE
208+
WHEN diff_rel_paths = [] THEN [NULL]
209+
ELSE diff_rel_paths
210+
END AS diff_rel_paths, has_more_data
204211
"""
205212

206213
def get_previous_base_path_query(self, db: InfrahubDatabase) -> str:

changelog/+diff_batch_bug.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a problem in the logic to calculate a diff that could cause it to quit too early under certain unlikely circumstances

0 commit comments

Comments
 (0)