Skip to content

Commit d5edaca

Browse files
committed
Skip malformed replies in thread context builder
Add || continue to jq extraction calls so a malformed comment entry is skipped rather than feeding empty/partial data to the agent.
1 parent 20fcc3d commit d5edaca

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

.github/workflows/review-pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,13 +418,13 @@ jobs:
418418
# to avoid duplication if the API already has it)
419419
reply_count=$(echo "$all_comments" | jq 'length')
420420
for i in $(seq 0 $((reply_count - 1))); do
421-
comment_id=$(echo "$all_comments" | jq -r ".[$i].id")
421+
comment_id=$(echo "$all_comments" | jq -r ".[$i].id") || continue
422422
# Skip the triggering comment — we append it from the payload below
423423
if [ "$comment_id" = "$TRIGGER_COMMENT_ID" ]; then
424424
continue
425425
fi
426-
author=$(echo "$all_comments" | jq -r ".[$i].user.login")
427-
body=$(echo "$all_comments" | jq -r ".[$i].body")
426+
author=$(echo "$all_comments" | jq -r ".[$i].user.login") || continue
427+
body=$(echo "$all_comments" | jq -r ".[$i].body") || continue
428428
echo "[REPLY by @$author]"
429429
echo "$body"
430430
echo ""

.github/workflows/self-review-pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,13 @@ jobs:
322322
# to avoid duplication if the API already has it)
323323
reply_count=$(echo "$all_comments" | jq 'length')
324324
for i in $(seq 0 $((reply_count - 1))); do
325-
comment_id=$(echo "$all_comments" | jq -r ".[$i].id")
325+
comment_id=$(echo "$all_comments" | jq -r ".[$i].id") || continue
326326
# Skip the triggering comment — we append it from the payload below
327327
if [ "$comment_id" = "$TRIGGER_COMMENT_ID" ]; then
328328
continue
329329
fi
330-
author=$(echo "$all_comments" | jq -r ".[$i].user.login")
331-
body=$(echo "$all_comments" | jq -r ".[$i].body")
330+
author=$(echo "$all_comments" | jq -r ".[$i].user.login") || continue
331+
body=$(echo "$all_comments" | jq -r ".[$i].body") || continue
332332
echo "[REPLY by @$author]"
333333
echo "$body"
334334
echo ""

0 commit comments

Comments
 (0)