Skip to content

Commit 25dfe5c

Browse files
ci: Improve pagination error handling in ci_changes_per_commit.py
- Add type checking for name parameter - Add validation for pagination direction - Add null check for cursor value - Improve error messages for invalid cases Co-Authored-By: bsatrom@blues.com <bsatrom@blues.com>
1 parent efa4908 commit 25dfe5c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tools/ci_changes_per_commit.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,25 @@ def paginate(self, page_info, name):
114114
if not isinstance(page_info, dict):
115115
return False
116116

117+
if not isinstance(name, str):
118+
print(f"Warning: Invalid name parameter type: {type(name)}")
119+
return False
120+
121+
if not (name.startswith("after") or name.startswith("before")):
122+
print(f"Warning: Invalid pagination direction: {name}")
123+
return False
124+
117125
page_type = "hasNextPage" if name.startswith("after") else "hasPreviousPage"
118126
cursor_type = "endCursor" if name.startswith("after") else "startCursor"
119127

120128
has_page = page_info.get(page_type, False)
121129
if has_page and cursor_type in page_info:
122-
self.variables[name] = page_info[cursor_type]
130+
cursor = page_info.get(cursor_type)
131+
if cursor is not None:
132+
self.variables[name] = cursor
133+
else:
134+
print(f"Warning: Missing {cursor_type} in page_info")
135+
return False
123136

124137
return has_page
125138

0 commit comments

Comments
 (0)