Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(readBody): validate requests with application/json content type #207

Merged
merged 18 commits into from
Jul 10, 2023

Conversation

tobiasdiez
Copy link
Contributor

@tobiasdiez tobiasdiez commented Oct 19, 2022

Follow-up from #201. Changes are:

@tobiasdiez tobiasdiez changed the title feat: throw errors if body json is not valid feat: throw error if body json is not valid Nov 12, 2022
@tobiasdiez
Copy link
Contributor Author

@pi0 this is now ready for review

@tobiasdiez tobiasdiez marked this pull request as ready for review November 12, 2022 20:01
@codecov
Copy link

codecov bot commented Nov 12, 2022

Codecov Report

Merging #207 (4c36817) into main (a5c8c9f) will increase coverage by 0.38%.
The diff coverage is 98.48%.

@@            Coverage Diff             @@
##             main     #207      +/-   ##
==========================================
+ Coverage   77.36%   77.74%   +0.38%     
==========================================
  Files          26       26              
  Lines        2655     2692      +37     
  Branches      383      393      +10     
==========================================
+ Hits         2054     2093      +39     
+ Misses        601      599       -2     
Impacted Files Coverage Δ
src/utils/body.ts 94.64% <98.48%> (+1.51%) ⬆️

... and 1 file with indirect coverage changes

@nopeless
Copy link

@tobiasdiez Nice pr; I ended up fixing the encoding signature too just to realize that you had a fix haha

@tobiasdiez
Copy link
Contributor Author

@pi0 merged in the latest version from main, so this PR is ready for review again

@tobiasdiez
Copy link
Contributor Author

@pi0 would appreciate if you could have a look at this PR. Thanks!

@T1B0
Copy link

T1B0 commented Apr 11, 2023

@tobiasdiez good PR 👍
@pi0 i was considering doing a PR for adding size limit to parse body, should i start it from this branch or main ?

@Hebilicious Hebilicious requested review from pi0 and Hebilicious and removed request for pi0 June 30, 2023 18:18
@Hebilicious Hebilicious self-assigned this Jun 30, 2023
@Hebilicious Hebilicious added the enhancement New feature or request label Jun 30, 2023 — with Volta.net
@Hebilicious Hebilicious requested a review from pi0 July 5, 2023 09:34
@Hebilicious
Copy link
Member

Hebilicious commented Jul 5, 2023

@pi0 I think this is overall a good change, would like to know what you think before approving. We would need to keep the tests and refactor the logic, as there's a lot of conflicts now.

@pi0 pi0 assigned pi0 and unassigned Hebilicious Jul 10, 2023
@pi0
Copy link
Member

pi0 commented Jul 10, 2023

Hi, dear @tobiasdiez, and sorry for checking this late.

Before merging, I made a few changes to fix the behavior matching PR description (we strictly validate json body only when application/json is passing otherwise using default defu behavior with a try-parse strategy which also ensures this is a non-breaking change).

n the future please consider splitting fixes to allow iterating faster and having a clear changelog 🙏🏼

Cheers!

@pi0 pi0 changed the title feat: throw error if body json is not valid feat(readBody): validate json requests with application/json content type Jul 10, 2023
@pi0 pi0 changed the title feat(readBody): validate json requests with application/json content type feat(readBody): validate requests with application/json content type Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong typing for readRawBody
5 participants