Skip to content

fix: treat envelope-shaped non-2xx as failure even when status is 0 - #8

Open
AshSgDe29071999 wants to merge 1 commit into
EverMind-AI:mainfrom
AshSgDe29071999:fix/http-non2xx-zero-status
Open

fix: treat envelope-shaped non-2xx as failure even when status is 0#8
AshSgDe29071999 wants to merge 1 commit into
EverMind-AI:mainfrom
AshSgDe29071999:fix/http-non2xx-zero-status

Conversation

@AshSgDe29071999

Copy link
Copy Markdown

Problem

(*httpClient).do treated any JSON body that unmarshaled as the backend envelope with status == 0 as success, without checking resp.StatusCode. json.Unmarshal zeroes a missing field, so a 500 whose body is envelope-shaped but has no explicit status returned err == nil.

Fixes #6.

Change

If envelope status is 0, also require HTTP 2xx. Non-2xx goes through the same auth / upstream classification as a non-JSON error body.

Test

go test ./internal/client -count=1 -run TestNon2xxEnvelopeWithZeroStatusIsNotSuccess
# ok

json.Unmarshal zeroes a missing status field, so a 500 whose body looks
like the success envelope used to return err == nil and advance callers.

Closes EverMind-AI#6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: HTTP non-2xx with envelope-shaped JSON body (status:0) is silently treated as success

1 participant