-
Notifications
You must be signed in to change notification settings - Fork 862
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
.NET 8: S3.PutObjectAsync request throws exception "Request headers must contain only ASCII characters." #3574
Comments
@indimini Good morning. Please share the following to troubleshoot the issue:
Thanks, |
@ashishdhingra - thanks for the quick response
This code works w/o issue on Windows, fails when deployed. I've verified that the putRequest.Headers object we pass to the put method has no entries.
|
You'll need to run this on your ECS cluster as well, but can you add AWSConfigs.LoggingConfig.LogTo = LoggingOptions.Console;
AWSConfigs.LoggingConfig.LogMetricsFormat = LogMetricsFormatOption.JSON;
AWSConfigs.LoggingConfig.LogResponses = ResponseLoggingOption.Always;
AWSConfigs.LoggingConfig.LogMetrics = true;
using var client= new AmazonS3Client();
await client.ListBucketsAsync(...); Example logs:
The SDK tries to fetch some information from the environment to build the user-agent, so I'm wondering if something wasn't parsed correctly. |
when I capture the logs in my dev environment, calling ListBucketsAsync(), I see the following: Amazon Verbose: 0 : Received response (truncated to 1024 bytes): [ |
@indimini Thanks for your reply. As @dscpinheiro mentioned, please collect logs from your ECS cluster as well. May be there is some extra header which is parsed by SDK which contains some characters not well handled. Also share the .NET 8 version used on both your dev environment and ECS cluster. There was a known issue in some .NET version, so just curious if it popped back up in .NET 8 in certain version. Thanks, |
@ashishdhingra - not sure how to get the logs from an ECS cluster. Any guidance is appreciated. The file version of System.Net.Http (where the exception is originating) is V 8.0.824.36612. |
@ashishdhingra - not sure if this helps, but I replaced the client.putObjectAsync() call with using the FileTransferUtility and still end up with the same Non-ASCII header exception. This is the code I tested with. This works when running on a Windows server (same behavior as the putObjectAsync())
|
@indimini Thanks, |
@indimini |
Here are the Amazon logs from our ECS deployment: |
If I try to capture results when making the put call, this is the only entry in the logs: |
It appears that the CultureInfo to the date to staring method does resolve this issue. |
Comments on closed issues are hard for our team to see. |
Describe the bug
In migrating to .NET 8, we've run into an issue when calling IAmazonS3.PutObjectAsync(). The call works when running on Windows (debug/dev environment), but when deployed to Linux servers (ECS/Fargate), any attempts to put an object results in the exception "Request headers must contain only ASCII characters".
The PutRequest object passed to the call contains no user-added headers, so it would appear that the offending header entry is being added within the call. The call stack from the exception thrown is as follows:
at System.Net.Http.HttpConnection.g__ThrowForInvalidCharEncoding|56_0()
at System.Net.Http.HttpConnection.WriteString(String s, Encoding encoding)
at System.Net.Http.HttpConnection.WriteHeaderCollection(HttpHeaders headers, String cookiesFromContainer)
at System.Net.Http.HttpConnection.WriteHeaders(HttpRequestMessage request, HttpMethod normalizedMethod)
at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at Amazon.Runtime.HttpWebRequestMessage.GetResponseAsync(CancellationToken cancellationToken)
at Amazon.Runtime.Internal.HttpHandler`1.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RedirectHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.Unmarshaller.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.S3.Internal.AmazonS3ResponseHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.Signer.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.S3.Internal.S3Express.S3ExpressPreSigner.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CredentialsRetriever.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.S3.Internal.AmazonS3ExceptionHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext)
Installed version of AWSSDK.S3 is 3.7.410.1, but I have tried the earlier version that worked with .NET 6 and still had the exception thrown.
Regression Issue
Expected Behavior
Call to PutObjectAsync() should succeed
Current Behavior
Exception thrown "Request headers must contain only ASCII characters."
Reproduction Steps
Deploy .NET 8 based code to ECS/Fargate Linux instance; call fails
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSSDK.S3 3.7.410.1
Targeted .NET Platform
.NET 8
Operating System and version
ECS/Fargate Linux instance
The text was updated successfully, but these errors were encountered: