Skip to content

UniversalPackages: Add better error handling when the web response doesn't return json#661

Merged
dfederm merged 1 commit intomainfrom
dfederm/upack-error-handling
Mar 11, 2026
Merged

UniversalPackages: Add better error handling when the web response doesn't return json#661
dfederm merged 1 commit intomainfrom
dfederm/upack-error-handling

Conversation

@dfederm
Copy link
Member

@dfederm dfederm commented Mar 10, 2026

A user is seeing the following error:

error MSB4018: The "DownloadUniversalPackages" task failed unexpectedly.
  System.Text.Json.JsonReaderException: '<' is an invalid start of a value. LineNumber: 2 | BytePositionInLine: 0.
     at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
     at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
     at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
     at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
     at System.Text.Json.Utf8JsonReader.Read()
     at System.Text.Json.JsonDocument.Parse(ReadOnlySpan`1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack)
     at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory`1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedArrayPoolBytes, PooledByteBufferWriter extraPooledByteBufferWriter)
     at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory`1 json, JsonDocumentOptions options)
     at System.Text.Json.JsonDocument.Parse(String json, JsonDocumentOptions options)
     at Microsoft.Build.UniversalPackages.DownloadUniversalPackages.GetArtifactToolReleaseInfo(String osName, String arch, String patVar)
     at Microsoft.Build.UniversalPackages.DownloadUniversalPackages.GetArtifactToolPath(String patVar)
     at Microsoft.Build.UniversalPackages.DownloadUniversalPackages.Execute()
     at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
     at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [C:\__w\1\s\dirs.proj]

This change improves the error handling to provide a friendlier message and include the actual response to help debugging.

@dfederm dfederm enabled auto-merge (squash) March 10, 2026 21:45
@dfederm
Copy link
Member Author

dfederm commented Mar 11, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dfederm dfederm merged commit 42c2739 into main Mar 11, 2026
7 checks passed
@dfederm dfederm deleted the dfederm/upack-error-handling branch March 11, 2026 19:46
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