Open cool-mist opened 7 months ago
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.
Not sure if the concerned azure sdk teams are notified, or if the teams care about issues reported on Github. This is a 30 second fix on the SDK code as outlined in the issue description.
For anyone else coming across this issue, a workaround of manually setting the Content to string.Empty works whenever this issue is seen
request.Content = new StringContent(string.Empty);
This should be set through a custom DelegatingHandler that is part of the http pipeline constructed and passed in to override the SDK transport.
Any plans to fix this ?
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. Runningdotnet 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.