Skip to content

fix(fixRequestBody): fix request body for empty JSON object requests#640

Merged
chimurai merged 2 commits intochimurai:masterfrom
mhassan1:fix/fix-request-body-empty-json
Jan 23, 2022
Merged

fix(fixRequestBody): fix request body for empty JSON object requests#640
chimurai merged 2 commits intochimurai:masterfrom
mhassan1:fix/fix-request-body-empty-json

Conversation

@mhassan1
Copy link
Copy Markdown
Contributor

Description

This PR fixes the fixRequestBody utility so that it treats empty object bodies like non-empty object bodies and fixes them, as expected.

Motivation and Context

The fixRequestBody utility contains a check for empty objects that results in early return:

if (!requestBody || !Object.keys(requestBody).length) {
return;
}

Currently, JSON requests with empty object payloads do not get their request bodies fixed by this utility, and the request to the target hangs while the target waits for a payload that will never arrive.

This PR removes the special handling for empty objects and treats them like any other object.

Resolves #639.

How has this been tested?

I ran the reproduction steps in #639 before and after the code change. I also updated automated tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Copy link
Copy Markdown

@eemelipa eemelipa left a comment

Choose a reason for hiding this comment

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

LGTM

Faced the same issue. Allowing empty objects in the body fixes it

@HappyColour
Copy link
Copy Markdown

This PR has been released right?

@eemelipa
Copy link
Copy Markdown

This PR has been released right?

I don't think so. The PR is still open and the library doesn't have the fix

@HappyColour
Copy link
Copy Markdown

This PR has been released right?

I don't think so. The PR is still open and the library doesn't have the fix

Thx bro @eemelipa,please confirm this pr has been merged @mhassan1.

@mhassan1
Copy link
Copy Markdown
Contributor Author

No, it is still open.

@chimurai
Copy link
Copy Markdown
Owner

chimurai commented Nov 28, 2021

Hi @mhassan1. I left a remark in the PR a while ago which hasn't been resolved.

Happy to merge it after it's fixed.

Edit: Sorry, review was pending all the time. (bad github ui/ux) Should be visible now.

@chimurai chimurai self-requested a review November 28, 2021 11:45
Comment thread test/unit/fix-request-body.spec.ts
@mhassan1
Copy link
Copy Markdown
Contributor Author

mhassan1 commented Dec 2, 2021

@chimurai This is ready for re-review.

@coveralls
Copy link
Copy Markdown

coveralls commented Dec 2, 2021

Coverage Status

Coverage remained the same at 98.86% when pulling ece40cb on mhassan1:fix/fix-request-body-empty-json into 6b5d7a8 on chimurai:master.

@chimurai chimurai changed the title Fix request body for empty JSON object requests fix(fixRequestBody): fix request body for empty JSON object requests Jan 23, 2022
@chimurai chimurai merged commit 2bddd38 into chimurai:master Jan 23, 2022
@chimurai
Copy link
Copy Markdown
Owner

Thanks @mhassan1 !

@chimurai
Copy link
Copy Markdown
Owner

published in [email protected]

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.

Empty JSON object does not get fixed by fixRequestBody

5 participants