From d03b44377d58ce5d7d9249faf5baa38320e3489b Mon Sep 17 00:00:00 2001 From: Agent Date: Sun, 5 Apr 2026 07:13:08 +0000 Subject: [PATCH] fix: fix: forge_api_paginate crashes on invalid JSON response (#194) --- lib/env.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/env.sh b/lib/env.sh index cc0906c..bf7a239 100755 --- a/lib/env.sh +++ b/lib/env.sh @@ -227,7 +227,8 @@ forge_api_all() { page=1 while true; do page_items=$(forge_api GET "${path_prefix}${sep}limit=50&page=${page}") - count=$(printf '%s' "$page_items" | jq 'length') + count=$(printf '%s' "$page_items" | jq 'length' 2>/dev/null) || count=0 + [ -z "$count" ] && count=0 [ "$count" -eq 0 ] && break all_items=$(printf '%s\n%s' "$all_items" "$page_items" | jq -s 'add') [ "$count" -lt 50 ] && break -- 2.49.1