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

Request payload corrupted when using System.Text.Json serializer #952

Closed
igorgiovannini opened this issue Jul 30, 2020 · 8 comments
Closed
Labels

Comments

@igorgiovannini
Copy link

igorgiovannini commented Jul 30, 2020

Describe the bug
When a request is serialized using SystemTextJsonContentSerializer, the request payload looks incomplete.

Steps To Reproduce
Send a request to a service using a payload with byte array and some other attributes (sorry, I can't attach a reproducible sample).

!! Instead, using NewtonsoftJsonContentSerializer the problem is not reproducible and everything works like expected.

Expected behavior
I expect that my request is being serialized in the right way without any data loss.

Environment

  • OS: macOS 10.15.5
  • .NET Core: 3.1.100
  • Refit: 5.1.67
@igorgiovannini igorgiovannini changed the title [BUG] Request payload corrupted when using System.Text.Json Request payload corrupted when using System.Text.Json Jul 30, 2020
@igorgiovannini igorgiovannini changed the title Request payload corrupted when using System.Text.Json Request payload corrupted when using System.Text.Json serializer Jul 30, 2020
@cocytus
Copy link
Contributor

cocytus commented Nov 25, 2020

I'm seeing this issue as well now. Sending a request containing a byte array, and the receiving side waits for data it never receives. Reading a single byte at the time from the incoming stream, its within the base64 encoded byte[] array.

@clairernovotny
Copy link
Member

We need a repro (failing test ideally) to figure out what's going on.... so far, all tests are passing and System.Text.Json is set to be the default in #1005

@clairernovotny
Copy link
Member

What does the object with the byte array / request look like so we can try to repro?

@cocytus
Copy link
Contributor

cocytus commented Nov 25, 2020

Created a test project outside refit source, since I was not able to create a failing test within the existing refit tests framework. You probably know how.. :-)

https://github.com/cocytus/RfTest -> This fails when the size of the array reaches 61400

GitHub
GitHub is where people build software. More than 50 million people use GitHub to discover, fork, and contribute to over 100 million projects.

@cocytus
Copy link
Contributor

cocytus commented Nov 26, 2020

I just got to test this using a locally compiled refit, by copying the refit stubs generator compile target from Refit.Tests.csproj. With the main branch checked out, the error does not occur. If i check out the commit tagged 5.2.1, it does occur. So it's fixed... whatever it was.

cocytus added a commit to cocytus/refit that referenced this issue Nov 26, 2020
cocytus added a commit to cocytus/refit that referenced this issue Nov 26, 2020
@cocytus
Copy link
Contributor

cocytus commented Nov 26, 2020

As is visible from PR, it seems like it was not actually fixed, just not visible, but for some users it might very well be.

cocytus added a commit to cocytus/refit that referenced this issue Nov 26, 2020
cocytus added a commit to cocytus/refit that referenced this issue Nov 26, 2020
clairernovotny added a commit that referenced this issue Nov 26, 2020
Fixes issue #952 - did not write everything to output stream
clairernovotny added a commit that referenced this issue Nov 26, 2020
Fixes issue #952 - did not write everything to output stream
@clairernovotny
Copy link
Member

clairernovotny commented Nov 26, 2020

This is fixed in version 5.2.4 (and 6.0-preview), just published to NuGet. Thank you @cocytus for the repro and patch!

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants