LG-10062 Accept compressed Service Provider#9074
Merged
Conversation
3 tasks
14449f7 to
be00975
Compare
mitchellhenke
approved these changes
Aug 24, 2023
zachmargolis
approved these changes
Aug 24, 2023
Contributor
zachmargolis
left a comment
There was a problem hiding this comment.
LGTM, one idea, but not a blocker
Comment on lines
+39
to
+45
| return {} unless request.headers['Content-Type'] == 'gzip/json' | ||
|
|
||
| body = request.body.read | ||
|
|
||
| return {} unless body.present? | ||
|
|
||
| JSON.parse(Zlib.gunzip(body)) |
Contributor
There was a problem hiding this comment.
So in my mind there are 3 cases we want to handle, in the spirit of "be liberal in what you accept, and strict in what you output":
- GZIP'ed JSON params
- regular JSON params
- form encoded params
So seeing this it seems like we just have empty params for anything that's not gzipped?
Is it possible to allow the other formats in addition to the GZIP? Like something like:
Suggested change
| return {} unless request.headers['Content-Type'] == 'gzip/json' | |
| body = request.body.read | |
| return {} unless body.present? | |
| JSON.parse(Zlib.gunzip(body)) | |
| if request.headers['Content-Type'] == 'gzip/json' | |
| body = request.body.read | |
| if body.present? | |
| JSON.parse(Zlib.gunzip(body)) | |
| else | |
| {} | |
| end | |
| elsif params.key?(:service_provider) # fall back to rails processing of params? | |
| params.permit(service_provider: {}) | |
| end |
Contributor
Author
There was a problem hiding this comment.
yeah i like that! thanks
zachmargolis
approved these changes
Aug 24, 2023
Merged
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.
🎫 Ticket
https://cm-jira.usa.gov/browse/LG-10062
🛠 Summary of changes
This ticket surfaced an issue where, when JSON requests to sync the service providers are over 20k, they are automatically rejected by nginx. We raised the nginx threshold, but also would like to compress requests to make sure the requests stay below the threshold.
It should be merged before 18F/identity-dashboard#667
📜 Testing Plan
Provide a checklist of steps to confirm the changes.
make runboth repos