Skip to content

Don't output body for json DELETE requests #650

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

Merged
merged 2 commits into from
Apr 16, 2025
Merged

Don't output body for json DELETE requests #650

merged 2 commits into from
Apr 16, 2025

Conversation

adam-fowler
Copy link
Member

@adam-fowler adam-fowler commented Apr 15, 2025

HTTP DELETE methods should not include a body. We were only checking for GET and HEAD method requests previously. It wasn't an issue but AWS lambda is now returning a signing error because of this. So I've added a check for DELETE method in the serialisation of json bodies.

EDIT: Verified it fixes signing issue with deleting lambdas

Copy link

codecov bot commented Apr 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.73%. Comparing base (4ae4688) to head (6fd28a5).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #650   +/-   ##
=======================================
  Coverage   80.73%   80.73%           
=======================================
  Files          83       83           
  Lines        7349     7352    +3     
=======================================
+ Hits         5933     5936    +3     
  Misses       1416     1416           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adam-fowler adam-fowler requested a review from 0xTim April 15, 2025 14:04
@@ -260,6 +261,8 @@ extension AWSHTTPRequest {
guard self.headers["content-type"].first == nil else {
return
}
// in theory we don't need this check as the check for an empty body should skip adding
// a header and a GET or HEAD request should have an empty body
guard self.method != .GET, self.method != .HEAD else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not want to check for DELTE here as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to add code that has the least effect. I can't trust there isn't a service that includes a body with a delete method. The code above basically removes the body if it is {}.

@adam-fowler adam-fowler merged commit bfe6d6f into main Apr 16, 2025
8 checks passed
@adam-fowler adam-fowler deleted the empty-delete branch April 16, 2025 16:54
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.

2 participants