buildkit
buildkit copied to clipboard
grpcerrors: adapt grpcerrors to support more enriched error structures
The grpcerrors package has been updated to support more enriched error structures.
The serialization structure has been changed to capture the original structure of the error and to serialize and deserialize into that same structure. Wrapped errors should be maintained with the same structure for unwrapping.
Unwrap() []error is now supported so errors.Join and anything else that wraps multiple errors can now be used and are serialized/deserialized correctly.
More methods of determining the grpc code are now supported and they will respect error wrapping. The errors in
github.com/containerd/errdefs are now also used for mapping error codes with more likely to appear in the future.
The marshaling will marshal both the new format and the old format in a way where a client that reads either will succeed. That makes this method compatible with old clients.
I still need to finish the v1 compatibility tests. I also discovered a bug in typeurl while I was working on this and that's filed here: https://github.com/containerd/typeurl/issues/47.
I tried to do this with just using the Status protobuf message but the implementation is so much easier and more future proof if I just add a single type rather than overload the status protobuf message. So, I've updated this with that implementation accordingly.
Closing this since it's been open awhile and there isn't a pressing need for this. I'll keep the code around but I don't want to keep an old PR around for no reason.