You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today, any implementation of RequestFailedDetailsParser where the response content is an unbuffered network stream must overwrite response.ContentStream in order to log the "Content:" portion of the RequestFailedException message. Ideally, since any RequestFailedDetailsParser implementation must read the stream content to parse the exception, the interface would allow the caller to pass back the content it read and populate the "Content" on the message from that.
There are a couple other things that would be good to do here as well:
We could centralize the content buffering in Core when we have an error message, so each customer parser doesn't have to do this, potentially in a different way
We could either remove the message formatting in ClientDiagnostics entirely, in favor of the RFE implementation, or make these share common code -- currently this code is duplicated and different, so exception messages could be different depending on the code path that is followed.
Related to, and potentially could be done holistically as part of work on:
We should consider that as part of this work, and update ContainerRegistryRequestFailedDetailsParser.cs to use the common buffering code when it's available.
If we assume that custom RequestFailedDetailsParser would like to parse the content, we can ensure the content stream is buffered (when content type header is present). That way, RequestFailedDetailsParser can directly call JsonDocument.Parse(response.ContentStream).
When RequestFailedDetailsParser is not specified, RequestFailedException.GetRequestFailedExceptionContent would call TryExtractErrorContent, which is not very effective (it creates readers and converts JSON input into UTF-16 string before converting it back). So using buffering code from ResponseBodyPolicy can help in the default case as well.
Today, any implementation of RequestFailedDetailsParser where the response content is an unbuffered network stream must overwrite response.ContentStream in order to log the "Content:" portion of the RequestFailedException message. Ideally, since any RequestFailedDetailsParser implementation must read the stream content to parse the exception, the interface would allow the caller to pass back the content it read and populate the "Content" on the message from that.
There are a couple other things that would be good to do here as well:
Related to, and potentially could be done holistically as part of work on:
The text was updated successfully, but these errors were encountered: