Docker.DotNet icon indicating copy to clipboard operation
Docker.DotNet copied to clipboard

Handling errors when building image

Open dermeister opened this issue 3 years ago • 5 comments

Output of dotnet --info:

.NET SDK (reflecting any global.json):
 Version:   6.0.100
 Commit:    9e8b04bbff

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.15
 OS Platform: Darwin
 RID:         osx.10.15-x64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.100/

Host (useful for support):
  Version: 6.0.0
  Commit:  4822e3c3aa

.NET SDKs installed:
  3.1.410 [/usr/local/share/dotnet/sdk]
  5.0.103 [/usr/local/share/dotnet/sdk]
  5.0.302 [/usr/local/share/dotnet/sdk]
  6.0.100 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.16 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.16 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

What version of Docker.DotNet?:

3.125.5

Steps to reproduce the issue:

  1. Try building image with invalid syntax in Dockerfile using BuildImageFromDockerfileAsync method.

What actually happened?: BuildImageFromDockerfileAsync doesn't throw any exception. Instead, it ignores status code and reports everything to IProgress<JSONMessage> instance. When Dockerfile contains syntax errors, docker daemon responds with status code 400 and body which cannot be deserialized to JSONMessage (it contains only "message" field), so it's impossible to handle exceptions from building image.

What did you expect to happen?: BuildImageFromDockerfileAsync should throw exception if daemon responds with error.

dermeister avatar Feb 08 '22 10:02 dermeister

And/Or, the JSONMessage needs to be updated to have a "message" field so that we can get the error from progress. Either way, can confirm that errors from Build and Create (and likely others) are basically being eaten. The only indication that anything went wrong was that nothing was return but a single hit to IProgress with an empty JSONMessage.

daniel-tonic avatar Mar 07 '22 19:03 daniel-tonic

I don't think that updating JSONMessage is a good idea, because it's generated from Docker sources and should be in sync with it. Plus, it would be inconsistent way of exception handling if we consider other API methods.

dermeister avatar Mar 17 '22 15:03 dermeister

@galvesribeiro We can close this issue.

HofmeisterAn avatar Sep 25 '22 20:09 HofmeisterAn

@galvesribeiro , I'm still new on GitHub process here, so do you know who will trigger a new release build so that the fix can be available to the official nuget packages? 😀

aDisplayName avatar Sep 26 '22 13:09 aDisplayName

Usually it depends how urgent the issue is. If it is not critical (like in this case) we probably collect some more fixes and publish them together. @galvesribeiro will do the release at some point.

HofmeisterAn avatar Sep 27 '22 10:09 HofmeisterAn