Skip to content

Commit 50b1267

Browse files
committed
fix: bail out on incomplete pagination instead of acting on partial data
When a GraphQL or jq error breaks the pagination loop mid-flight, skip resolution entirely rather than proceeding with threads from only the earlier pages. This prevents incorrectly leaving threads open (or resolving them) based on an incomplete view.
1 parent d735414 commit 50b1267

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

review-pr/action.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ runs:
237237
ALL_THREADS="[]"
238238
CURSOR=""
239239
PAGE=0
240+
FETCH_OK=true
240241
241242
while true; do
242243
PAGE=$((PAGE + 1))
@@ -248,21 +249,25 @@ runs:
248249
249250
RESULT=$(gh api graphql "${GQL_ARGS[@]}" 2>&1) || {
250251
echo "::warning::GraphQL query failed (page $PAGE): $RESULT"
251-
exit 0
252+
FETCH_OK=false
253+
break
252254
}
253255
254256
# Check for GraphQL errors in response (HTTP 200 can still contain errors)
255257
if echo "$RESULT" | jq -e '.errors' > /dev/null 2>&1; then
256258
echo "::warning::GraphQL returned errors: $(echo "$RESULT" | jq -c '.errors')"
257-
exit 0
259+
FETCH_OK=false
260+
break
258261
fi
259262
260263
THREADS=$(echo "$RESULT" | jq '.data.repository.pullRequest.reviewThreads.nodes // []') || {
261264
echo "::warning::Failed to parse threads on page $PAGE"
265+
FETCH_OK=false
262266
break
263267
}
264268
ALL_THREADS=$(echo "$ALL_THREADS" "$THREADS" | jq -s '.[0] + .[1]') || {
265269
echo "::warning::Failed to merge threads on page $PAGE"
270+
FETCH_OK=false
266271
break
267272
}
268273
@@ -273,6 +278,11 @@ runs:
273278
CURSOR=$(echo "$RESULT" | jq -r '.data.repository.pullRequest.reviewThreads.pageInfo.endCursor')
274279
done
275280
281+
if [ "$FETCH_OK" != "true" ]; then
282+
echo "::warning::Thread fetch incomplete — skipping resolution to avoid acting on partial data"
283+
exit 0
284+
fi
285+
276286
TOTAL_THREADS=$(echo "$ALL_THREADS" | jq 'length')
277287
echo "📋 Fetched $TOTAL_THREADS review threads (across $PAGE page(s))"
278288

0 commit comments

Comments
 (0)