Maximum number of bytes exceeded
@gathogojr is already working on this.
Since Oct 11, 2022.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
Assemblies affected
ASP.NET Core OData 8.0.8
Describe the bug
Maximum number of bytes exceeded when calling an action.
Reproduce steps
Call an action such as:
[HttpPost("/api/ImportItems()")]
public async Task<IActionResult> ImportItems([FromODataBody] byte[] data)
with a data size > 2MB
Expected behavior
Being able to receive the data.
Additional context
Microsoft.OData.ODataException: The maximum number of bytes allowed to be read from the stream has been exceeded. After the last read operation, a total of 1114112 bytes has been read from the stream; however a maximum of 1048576 bytes is allowed.
at Microsoft.OData.MessageStreamWrapper.MessageStreamWrappingStream.IncreaseTotalBytesRead(Int32 bytesRead)
at Microsoft.OData.MessageStreamWrapper.MessageStreamWrappingStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
If I do
ODataMessageReaderSettings settings = this.HttpContext.Request.GetReaderSettings();
in another method in the same controller, I can see that settings.MessageQuotas.MaxReceivedMessageSize is 9223372036854775807.
The maximum size mentioned in the exception seems to be:
/// <summary>The default maximum number of bytes that should be read from a message.</summary>
internal const long DefaultMaxReadMessageSize = 1024 * 1024;
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.