fetchAllPages silently returns an empty list when the response is not an array #5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
fetchAllPagesinsrc/issue-helpers.jsassumes a successful response body is always an array:If the endpoint returns HTTP 200 with a non-array body (an object, or an HTML page that happened to carry a JSON content type - plausible here since git.trtmn.io sits behind Cloudflare Access and can serve a login page), then:
res.data.lengthisundefined, so!undefinedis true and the loop breaks immediately[]resolveLabelIdsthen reports every requested label as "not found ... skipped"create_issuesucceeds with no labels attached and only a soft warningSo a transport or auth problem is misreported as "your label names are wrong". Worst case,
res.data.pushon a string body would throw a confusing spread error instead.Suggested fix
Validate the shape before use and fail loudly:
Keep the existing
MAX_PAGESguard. Consider also surfacing whenMAX_PAGESis hit, since silently truncating at 500 items would produce the same class of misleading "not found" warning.Severity
Low - but it converts an infrastructure failure into a misleading user-facing message, which costs debugging time.