fix: fix: forge_api_paginate crashes on invalid JSON response (#194) #203

Merged
dev-qwen merged 1 commit from fix/issue-194-1 into main 2026-04-05 07:19:18 +00:00
Collaborator

Fixes #194

Changes

Fixes #194 ## Changes
dev-qwen added 1 commit 2026-04-05 07:13:16 +00:00
fix: fix: forge_api_paginate crashes on invalid JSON response (#194)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/pr/smoke-init Pipeline was successful
d03b44377d
Collaborator

AI Review

Summary

Bug fix for crashing when the Forge API returns a 200 OK with invalid/non-JSON body. With set -euo pipefail, jq 'length' failing on bad input aborts the script — the fix catches this and breaks the loop cleanly.

Analysis

  • **** suppresses jq's parse-error output to stderr.
  • || count=0 handles jq non-zero exit (invalid JSON → count=0 → loop breaks).
  • [ -z "$count" ] && count=0 is belt-and-suspenders for an empty-output edge case; harmless.
  • If count=0, the loop breaks before jq -s 'add' is reached, so invalid JSON never propagates to that line. The logic is coherent.
  • The fix is correctly scoped: HTTP-level failures (curl -sf exits non-zero) already abort at the page_items=$(forge_api ...) assignment line — this fix covers the gap for valid HTTP 200 with bad JSON body.

No issues found.

Verdict

APPROVE — Correct minimal fix: jq failure on invalid JSON is safely caught, loop breaks before add, logic is sound


Reviewed at d03b443 | AGENTS.md

## AI Review <!-- reviewed: d03b44377d58ce5d7d9249faf5baa38320e3489b --> ### Summary Bug fix for crashing when the Forge API returns a 200 OK with invalid/non-JSON body. With `set -euo pipefail`, `jq 'length'` failing on bad input aborts the script — the fix catches this and breaks the loop cleanly. ### Analysis - **** suppresses jq's parse-error output to stderr. - **`|| count=0`** handles jq non-zero exit (invalid JSON → count=0 → loop breaks). - **`[ -z "$count" ] && count=0`** is belt-and-suspenders for an empty-output edge case; harmless. - If `count=0`, the loop breaks before `jq -s 'add'` is reached, so invalid JSON never propagates to that line. The logic is coherent. - The fix is correctly scoped: HTTP-level failures (curl -sf exits non-zero) already abort at the `page_items=$(forge_api ...)` assignment line — this fix covers the gap for valid HTTP 200 with bad JSON body. No issues found. ### Verdict **APPROVE** — Correct minimal fix: jq failure on invalid JSON is safely caught, loop breaks before add, logic is sound --- *Reviewed at `d03b443` | [AGENTS.md](AGENTS.md)*
review-bot approved these changes 2026-04-05 07:17:57 +00:00
review-bot left a comment
Collaborator

AI Review: APPROVE — Correct minimal fix: jq failure on invalid JSON is safely caught, loop breaks before add, logic is sound

AI Review: **APPROVE** — Correct minimal fix: jq failure on invalid JSON is safely caught, loop breaks before add, logic is sound
dev-qwen merged commit a5c2ef1d99 into main 2026-04-05 07:19:18 +00:00
dev-qwen deleted branch fix/issue-194-1 2026-04-05 07:19:18 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: johba/disinto#203
No description provided.