You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Making removal of space from JSON encoding configurable and documenting the behaviour #3563
This is regarding the issue #3363 which was fixed as a part of #3367.
We discovered that manually encoding the JSON versus using HTTPX’s built-in encoding produces different outputs due to missing spaces, this in our case broke our cryptographic signature validation.
Could we add a note about this in the docs and perhaps expose a flag to disable HTTPX’s JSON encoder?
This actually does more than the CHANGELOG says: it doesn't just require us to change our test suites, it requires us to change the way that we create signed requests, and the only way to understand that is to go diving into past PRs in this repository to understand what exactly the change is and how to work around it.
In our specific case, this change breaks AWS V4 request signing by changing the content of the request body sent, so it no longer matches the content that was used to create the request signature. I believe the specific change that is causing the problem is the removal of spaces between separators.
From the perspective of a user of the library, I definitely don't expect that the request content body will be transformed in flight. To work around it, I need to use the same JSON encoding that httpx uses under the hood in a private module and emulate that when signing my request, but this isn't explicitly declared in either the changelog or httpx docs.
So, no, it's not enough to say "the compact style is documented in the release notes". This breaks the way cryptographic signing works, simple as, and essentially means we, as users, need to follow very specific, obscure encoding of content to make it compatible with your library, or we just need to never update past 0.27.
Please consider reverting the change where content is transformed in flight (and, if a user desires a compact format, leave that up to them), or let us configure the behavior at the time we make a request.
Activity
lovelydinosaur commentedon May 6, 2025
The compact style is documented in the 0.28.0 release notes. We will not be adding a switch for this behavior.
eightyeighteyes commentedon Sep 16, 2025
This actually does more than the CHANGELOG says: it doesn't just require us to change our test suites, it requires us to change the way that we create signed requests, and the only way to understand that is to go diving into past PRs in this repository to understand what exactly the change is and how to work around it.
In our specific case, this change breaks AWS V4 request signing by changing the content of the request body sent, so it no longer matches the content that was used to create the request signature. I believe the specific change that is causing the problem is the removal of spaces between separators.
From the perspective of a user of the library, I definitely don't expect that the request content body will be transformed in flight. To work around it, I need to use the same JSON encoding that httpx uses under the hood in a private module and emulate that when signing my request, but this isn't explicitly declared in either the changelog or httpx docs.
So, no, it's not enough to say "the compact style is documented in the release notes". This breaks the way cryptographic signing works, simple as, and essentially means we, as users, need to follow very specific, obscure encoding of content to make it compatible with your library, or we just need to never update past 0.27.
Please consider reverting the change where content is transformed in flight (and, if a user desires a compact format, leave that up to them), or let us configure the behavior at the time we make a request.
lovelydinosaur commentedon Sep 16, 2025
No. It does exactly what the CHANGELOG entry states.
"JSON request bodies use a compact representation." (#3363)
Nothing is changed "in flight".
You're welcome to pin to earlier versions if you want a verbose JSON encoding by default.
lovelydinosaur commentedon Oct 7, 2025
Banning the trolls for trolling, and deleting the pointless gumpf.