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

Deal with non-XML errors #1196

Merged
merged 1 commit into from
Oct 19, 2024
Merged

Conversation

ramondeklein
Copy link
Contributor

If an error is returned that is not XML, then it crashes the SDK. This PR will deal with that and try to give some information.

@ramondeklein ramondeklein self-assigned this Oct 18, 2024
@ramondeklein ramondeklein marked this pull request as draft October 18, 2024 09:05
@ramondeklein ramondeklein changed the base branch from master to 5.x October 18, 2024 09:06
@ramondeklein ramondeklein marked this pull request as ready for review October 18, 2024 09:06
Copy link
Collaborator

@ebozduman ebozduman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?

@@ -582,7 +582,34 @@ private static void ParseErrorFromContent(ResponseResult response)
throw new BucketNotFoundException(bucketName, "Not found.");
}

// TODO: This is rather inefficient, because it reads everything into memory
using var stream = Encoding.UTF8.GetBytes(response.Content).AsMemory().AsStream();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using var stream = Encoding.UTF8.GetBytes(response.Content).AsMemory().AsStream();
using var stream = response.ContentBytes.AsStream();

Copy link
Collaborator

@ebozduman ebozduman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disclaimer: This is an opinion based comment.
When "500 internal error happens" status code comes from the server side, we are expected handle it gracefully.
It is fine, but the console output looks too crowded to me and we call it "Internal Server Error" so I am afraid it might cause a support call. Maybe!

$ time dotnet run --project Minio.Functional.Tests/Minio.Functional.Tests.csproj --framework net6.0
{"name":"minio-dotnet : PutObject_Test2","function":"Task PutObjectAsync(PutObjectArgs args, CancellationToken cancellationToken = default(CancellationToken))","description":"Tests whether multipart PutObject passes","args":{"bucketName":"ersbucket","objectName":"a+a+#+{a%&","contentType":"binary/octet-stream","size":"6MB"},"duration":4523,"status":"FAIL","alert":"","message":"MinIO API responded with message=Backend returned status-code InternalServerError\nResponse: <html>\r\n<head><title>500 Internal Server Error</title></head>\r\n<body>\r\n<center><h1>500 Internal Server Error</h1></center>\r\n<hr><center>nginx/1.18.0 (Ubuntu)</center>\r\n</body>\r\n</html>\r\n\nNo request ID (check if endpoint is an S3 endpoint)\n","error":"Minio.Exceptions.UnexpectedMinioException: MinIO API responded with message=Backend returned status-code InternalServerError\nResponse: <html>\r\n<head><title>500 Internal Server Error</title></head>\r\n<body>\r\n<center><h1>500 Internal Server Error</h1></center>\r\n<hr><center>nginx/1.18.0 (Ubuntu)</center>\r\n</body>\r\n</html>\r\n\nNo request ID (check if endpoint is an S3 endpoint)\n\n   at Minio.MinioClient.ParseErrorFromContent(ResponseResult response) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/MinioClient.cs:line 693\n   at Minio.MinioClient.ParseError(ResponseResult response) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/MinioClient.cs:line 475\n   at Minio.MinioClient.<>c.<.ctor>b__94_0(ResponseResult response) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/MinioClient.cs:line 48\n   at Minio.MinioClient.HandleIfErrorResponse(ResponseResult response, IEnumerable`1 handlers, DateTime startTime) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/MinioClient.cs:line 720\n   at Minio.MinioClient.ExecuteTaskCoreAsync(IEnumerable`1 errorHandlers, HttpRequestMessageBuilder requestMessageBuilder, Boolean isSts, CancellationToken cancellationToken) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/MinioClient.cs:line 449\n   at Minio.MinioClient.PutObjectSinglePartAsync(PutObjectArgs args, CancellationToken cancellationToken) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/ApiEndpoints/ObjectOperations.cs:line 823\n   at Minio.MinioClient.PutObjectPartAsync(PutObjectPartArgs args, CancellationToken cancellationToken) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/ApiEndpoints/ObjectOperations.cs:line 867\n   at Minio.MinioClient.PutObjectAsync(PutObjectArgs args, CancellationToken cancellationToken) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/ApiEndpoints/ObjectOperations.cs:line 617\n   at Minio.Functional.Tests.FunctionalTest.PutObject_Tester(MinioClient minio, String bucketName, String objectName, String fileName, String contentType, Int64 size, Dictionary`2 metaData, Stream mstream) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio.Functional.Tests/FunctionalTest.cs:line 1004\n   at Minio.Functional.Tests.FunctionalTest.PutObject_Test2(MinioClient minio) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio.Functional.Tests/FunctionalTest.cs:line 3281"}
Unhandled exception. Minio.Exceptions.UnexpectedMinioException: MinIO API responded with message=Backend returned status-code InternalServerError
Response: <html>
<head><title>500 Internal Server Error</title></head>
<body>
<center><h1>500 Internal Server Error</h1></center>
<hr><center>nginx/1.18.0 (Ubuntu)</center>
</body>
</html>

No request ID (check if endpoint is an S3 endpoint)

   at Minio.MinioClient.ParseErrorFromContent(ResponseResult response) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/MinioClient.cs:line 693
   at Minio.MinioClient.ParseError(ResponseResult response) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/MinioClient.cs:line 475
   at Minio.MinioClient.<>c.<.ctor>b__94_0(ResponseResult response) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/MinioClient.cs:line 48
   at Minio.MinioClient.HandleIfErrorResponse(ResponseResult response, IEnumerable`1 handlers, DateTime startTime) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/MinioClient.cs:line 720
   at Minio.MinioClient.ExecuteTaskCoreAsync(IEnumerable`1 errorHandlers, HttpRequestMessageBuilder requestMessageBuilder, Boolean isSts, CancellationToken cancellationToken) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/MinioClient.cs:line 449
   at Minio.MinioClient.PutObjectSinglePartAsync(PutObjectArgs args, CancellationToken cancellationToken) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/ApiEndpoints/ObjectOperations.cs:line 823
   at Minio.MinioClient.PutObjectPartAsync(PutObjectPartArgs args, CancellationToken cancellationToken) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/ApiEndpoints/ObjectOperations.cs:line 867
   at Minio.MinioClient.PutObjectAsync(PutObjectArgs args, CancellationToken cancellationToken) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio/ApiEndpoints/ObjectOperations.cs:line 617
   at Minio.Functional.Tests.FunctionalTest.PutObject_Tester(MinioClient minio, String bucketName, String objectName, String fileName, String contentType, Int64 size, Dictionary`2 metaData, Stream mstream) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio.Functional.Tests/FunctionalTest.cs:line 1004
   at Minio.Functional.Tests.FunctionalTest.PutObject_Test2(MinioClient minio) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio.Functional.Tests/FunctionalTest.cs:line 3281
   at Minio.Functional.Tests.FunctionalTest.PutObject_Test2(MinioClient minio) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio.Functional.Tests/FunctionalTest.cs:line 3295
   at Minio.Functional.Tests.Program.Main(String[] args) in /home/ersan/work/src/github.com/minio/minio-dotnet/Minio.Functional.Tests/Program.cs:line 131
   at Minio.Functional.Tests.Program.<Main>(String[] args)

real	0m18.281s
user	0m11.953s
sys	0m0.787s

It sounds like this is an internal MinIO error. To prevent a possible support request, can we be more clear, like telling the user to check and make sure their MinIO server is up and running and responding?
The existing message is "No request ID (check if endpoint is an S3 endpoint)". If this is good enough, then you can ignore this comment.

Copy link
Collaborator

@ebozduman ebozduman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ebozduman ebozduman merged commit 1ecf1a4 into minio:5.x Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants