Skip to content

fix: wrap non-JSON responses in EnableBankingException#6

Merged
ivan-holvi merged 2 commits into
nocfo:mainfrom
ivan-holvi:ijmartin/wrap-jsondecode
Jul 9, 2026
Merged

fix: wrap non-JSON responses in EnableBankingException#6
ivan-holvi merged 2 commits into
nocfo:mainfrom
ivan-holvi:ijmartin/wrap-jsondecode

Conversation

@ivan-holvi

@ivan-holvi ivan-holvi commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • _request only wrapped HTTP errors (raise_for_status) into EnableBankingException
  • A successful status code with a non-JSON body (e.g. an empty 200) makes response.json() raise a raw requests.exceptions.JSONDecodeError, which leaks past consumers that only catch EnableBankingException
  • Catch it and re-raise as EnableBankingException, keeping the response attached so callers can still inspect the status code
  • Added unit tests for the non-JSON-body and HTTP-error wrapping paths (_request's error handling was previously untested)

_request only wrapped HTTP errors (raise_for_status) into
EnableBankingException. A successful status code with a non-JSON body
(e.g. an empty 200 response) made response.json() raise requests'
JSONDecodeError, which leaked to callers instead of being handled like
any other request failure. Catch it and wrap it, attaching the response
so callers can still inspect the status code.
@ivan-holvi
ivan-holvi requested a review from juhoen July 9, 2026 14:33
@ivan-holvi
ivan-holvi merged commit 327bf1b into nocfo:main Jul 9, 2026
1 check passed
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.

1 participant