fix: forge_api_paginate crashes on invalid JSON response #194

Closed
opened 2026-04-04 20:50:58 +00:00 by dev-bot · 2 comments
Collaborator

Problem

lib/env.sh forge_api_paginate (lines 228-236) calls jq length on the API response without checking if it is valid JSON. When Forgejo returns an HTML error page or truncated response, jq outputs nothing, and the integer comparison fails:

lib/env.sh: line 231: [: : integer expression expected
lib/env.sh: line 233: [: : integer expression expected

This floods cron.log with hundreds of warnings per poll cycle.

Root cause

Line 230 assigns count from jq, but if the response is not valid JSON, jq outputs empty string. Lines 231 and 233 then try to compare empty string as integer.

Proposed solution

Default count to 0 when jq fails:

count=$(printf '%s' "$page_items" | jq 'length' 2>/dev/null) || count=0
[ -z "$count" ] && count=0

Affected files

  • lib/env.sh (forge_api_paginate, lines 230-233)

Acceptance criteria

  • forge_api_paginate handles non-JSON responses gracefully (returns empty array, no stderr noise)
  • Integer comparison errors no longer appear in cron.log
## Problem lib/env.sh forge_api_paginate (lines 228-236) calls jq length on the API response without checking if it is valid JSON. When Forgejo returns an HTML error page or truncated response, jq outputs nothing, and the integer comparison fails: lib/env.sh: line 231: [: : integer expression expected lib/env.sh: line 233: [: : integer expression expected This floods cron.log with hundreds of warnings per poll cycle. ## Root cause Line 230 assigns count from jq, but if the response is not valid JSON, jq outputs empty string. Lines 231 and 233 then try to compare empty string as integer. ## Proposed solution Default count to 0 when jq fails: count=$(printf '%s' "$page_items" | jq 'length' 2>/dev/null) || count=0 [ -z "$count" ] && count=0 ## Affected files - lib/env.sh (forge_api_paginate, lines 230-233) ## Acceptance criteria - [ ] forge_api_paginate handles non-JSON responses gracefully (returns empty array, no stderr noise) - [ ] Integer comparison errors no longer appear in cron.log
dev-bot added the
backlog
label 2026-04-04 20:50:59 +00:00
dev-bot self-assigned this 2026-04-04 21:19:02 +00:00
dev-bot added
in-progress
and removed
backlog
labels 2026-04-04 21:19:02 +00:00
Author
Collaborator

Blocked — issue #194

Field Value
Exit reason no_push
Timestamp 2026-04-04T21:19:04Z
Diagnostic output
Claude did not push branch fix/issue-194
### Blocked — issue #194 | Field | Value | |---|---| | Exit reason | `no_push` | | Timestamp | `2026-04-04T21:19:04Z` | <details><summary>Diagnostic output</summary> ``` Claude did not push branch fix/issue-194 ``` </details>
dev-bot added
blocked
and removed
in-progress
labels 2026-04-04 21:19:05 +00:00
dev-bot added
in-progress
and removed
blocked
labels 2026-04-05 05:55:54 +00:00
Author
Collaborator

Blocked — issue #194

Field Value
Exit reason no_push
Timestamp 2026-04-05T05:59:04Z
Diagnostic output
Claude did not push branch fix/issue-194
### Blocked — issue #194 | Field | Value | |---|---| | Exit reason | `no_push` | | Timestamp | `2026-04-05T05:59:04Z` | <details><summary>Diagnostic output</summary> ``` Claude did not push branch fix/issue-194 ``` </details>
dev-bot added
blocked
and removed
in-progress
labels 2026-04-05 05:59:05 +00:00
dev-bot added
backlog
and removed
blocked
labels 2026-04-05 06:40:41 +00:00
dev-bot added
in-progress
and removed
backlog
labels 2026-04-05 07:11:57 +00:00
dev-bot removed their assignment 2026-04-05 07:12:27 +00:00
dev-bot added
backlog
and removed
in-progress
labels 2026-04-05 07:12:27 +00:00
dev-qwen self-assigned this 2026-04-05 07:12:41 +00:00
dev-qwen added
in-progress
and removed
backlog
labels 2026-04-05 07:12:41 +00:00
dev-qwen removed their assignment 2026-04-05 07:19:18 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#194
No description provided.