Skip to content

Commit 61a7ca7

Browse files
Allow response location to be null (#221)
This happens at least sometimes on ACR push.
1 parent ad6b160 commit 61a7ca7

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

Microsoft.NET.Build.Containers/Registry.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ private readonly async Task UploadBlob(string name, string digest, Stream conten
113113

114114
Debug.Assert(pushResponse.StatusCode == HttpStatusCode.Accepted);
115115

116-
//Uri uploadUri = new(BaseUri, pushResponse.Headers.GetValues("location").Single() + $"?digest={layer.Descriptor.Digest}");
117-
Debug.Assert(pushResponse.Headers.Location is not null);
118-
119116
UriBuilder x;
120117
if (pushResponse.Headers.Location is {IsAbsoluteUri: true })
121118
{
@@ -125,7 +122,7 @@ private readonly async Task UploadBlob(string name, string digest, Stream conten
125122
{
126123
// if we don't trim the BaseUri and relative Uri of slashes, you can get invalid urls.
127124
// Uri constructor does this on our behalf.
128-
x = new UriBuilder(new Uri(BaseUri, pushResponse.Headers.Location.OriginalString));
125+
x = new UriBuilder(new Uri(BaseUri, pushResponse.Headers.Location?.OriginalString ?? ""));
129126
}
130127

131128
x.Query += $"&digest={Uri.EscapeDataString(digest)}";

0 commit comments

Comments
 (0)