Repository navigation
fix: check status code before decoding getJSON responses (!strims) - #66
Merged
Merged
Conversation
Contributor
Author
|
cc @jbpratt @xDashh @slugalisk @real-salad @tensei @HoppenR @SoMuchForSubtlety @talleyp @x-Xymos — could one of you take a look? I don't have permissions to formally request reviewers on this repo. |
getJSON (backing getStreamList / !strims and getProfileInfo) already closes the response body since the Modernize refactor, but still decodes whatever body comes back regardless of status. A non-200 response (5xx, rate limiting, WAF/edge error page, etc.) gets fed straight into json.Decoder, producing either a confusing decode error or, if the error body happens to be valid JSON of a different shape, a silently empty result instead of a clear error. Check resp.StatusCode and fail fast with a descriptive error before decoding.
nom-d-plume
force-pushed
the
feature/strims-command
branch
from
September 27, 2026 18:36
c5670a3 to
f715642
Compare
Contributor
Author
|
Rebased onto master (#65 already fixed the resp.Body leak via the getJSON refactor — thanks for that). Retargeted this to the remaining gap: getJSON decoding non-200 responses without checking status code. No conflicts now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
!strims/!streamhas been returningerror getting api datain chat.Root cause
This was originally an unclosed
resp.Bodyleak ingetStreamList,which #65 (Modernize) already fixed as part of the
getJSONrefactor.Rebased onto that; the remaining gap is that
getJSON(backinggetStreamList/!strimsandgetProfileInfo) still decodes theresponse body regardless of
resp.StatusCode. A non-200 response(5xx, rate limiting, an edge/WAF error page, etc.) gets fed straight
into
json.Decoder, producing either a confusing decode error or asilently empty result if the error body happens to parse as valid
JSON of a different shape.
Fix
Check
resp.StatusCodeingetJSONand fail fast with a descriptiveerror before decoding.
Verification
go build ./...,go vet ./...,go test ./...all pass.printTopStreamswithlogOnly=trueagainst thelive
https://strims.gg/apiendpoint on top of current master;confirmed it returns the top 3 streams correctly, e.g.: