[BUG] ADLS SDK does not add Content-Length = 0 for flush requests explicitly #43162
Labels
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
needs-team-attention
This issue needs attention from Azure service team or SDK team
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Service Attention
This issue is responsible by Azure service team.
Storage
Storage Service (Queues, Blobs, Files)
Overview
The c# SDK code to flush data is buggy, but the bug is masked by an implementation detail of HttpClientHandler.
Library name and version
Azure.Storage.Files.DataLake : 12.17.1
Possibly affects all earlier versions
Details
When using the FlushAsync, the c sharp SDK does not explicitly add the
Content-Length = 0
that is documented in the rest api documentation -However, the SDK code CreateFlushDataRequest does not take care of adding the
Content-Length
header. For flush, it should always be set to0
.This is not an issue when using the SDK under default settings, when the HttpClientTransport is not overridden. When it is not overridden, the SDK uses the default HttpClientHandler that adds the
Content-Length
header with value0
when the header is not already present, in both .NET Framework and .NET.NET
It uses SocketsHttpHandler by default and this line adds the
Content-Length
header with value0
.NET Framework
It uses HttpClientHandler by default and this line performs similar handling.
The problem
When configuring non-default transports (such as WinHttpHandler), calling flush results in SDK throwing the following exception
Reproduction Steps
Added it here as a gist.
Platform : Dotnet 8
Dependencies
Running
dotnet run
will succeed as it uses the defaults.Running
dotnet run -- w
will fail as it uses the WinHttpHandler.The logs print the request message before being passed on to the underlying handler. In both cases, we can see that for the Flush request, Content-Length header is not added explicitly.
The following exception will be printed when running
dotnet run -- w
Fix
Explicitly add
Content-Length = 0
in this method that is responsible for creating the FlushRequest.Other notes
The current SDK code is accepting a
long? contentLength
as an argument while creating a http request for the flush operation. That is unnecessary, as it should always be 0 anyways.The text was updated successfully, but these errors were encountered: