Skip to content

CLI searching for templates failed with JsonReaderException: 'W' is an invalid start of a value. and stack #9368

@danmoseley

Description

@danmoseley

I assume we just got a bad response from the server. Need to catch JsonReaderException. Unless @mitchdenny philosophically should this be a bug aginst the dotnet CLI?

C:\git\aspire>C:\git\aspire\artifacts\bin\Aspire.Cli\Debug\net8.0\aspire.exe new
Enter the project name: (aspire): xx
Enter the output path: (./x): ./xx
Unhandled exception: System.Text.Json.JsonReaderException: 'W' is an invalid start of a value. LineNumber: 1 | 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 Aspire.Cli.DotNetCliRunner.SearchPackagesAsync(DirectoryInfo workingDirectory, String query, Boolean prerelease, Int32 take, Int32 skip, String nugetSource, DotNetCliRunnerInvocationOptions options, CancellationToken cancellationToken) in C:\git\aspire\src\Aspire.Cli\DotNetCliRunner.cs:line 662
   at Aspire.Cli.NuGetPackageCache.GetPackagesAsync(DirectoryInfo workingDirectory, String query, Boolean prerelease, String source, CancellationToken cancellationToken) in C:\git\aspire\src\Aspire.Cli\NuGetPackageCache.cs:line 44
   at Aspire.Cli.NuGetPackageCache.GetTemplatePackagesAsync(DirectoryInfo workingDirectory, Boolean prerelease, String source, CancellationToken cancellationToken) in C:\git\aspire\src\Aspire.Cli\NuGetPackageCache.cs:line 23
   at Spectre.Console.Status.<>c__DisplayClass17_0`1.<<StartAsync>b__0>d.MoveNext() in /_/src/Spectre.Console/Live/Status/Status.cs:line 120
--- End of stack trace from previous location ---
   at Spectre.Console.Progress.<>c__DisplayClass32_0`1.<<StartAsync>b__0>d.MoveNext() in /_/src/Spectre.Console/Live/Progress/Progress.cs:line 138
--- End of stack trace from previous location ---
   at Spectre.Console.Internal.DefaultExclusivityMode.RunAsync[T](Func`1 func) in /_/src/Spectre.Console/Internal/DefaultExclusivityMode.cs:line 40
   at Spectre.Console.Progress.StartAsync[T](Func`2 action) in /_/src/Spectre.Console/Live/Progress/Progress.cs:line 121
   at Spectre.Console.Status.StartAsync[T](String status, Func`2 func) in /_/src/Spectre.Console/Live/Status/Status.cs:line 117
   at Aspire.Cli.Interaction.InteractionService.ShowStatusAsync[T](String statusText, Func`1 action) in C:\git\aspire\src\Aspire.Cli\Interaction\InteractionService.cs:line 22
   at Aspire.Cli.Commands.NewCommand.GetProjectTemplatesVersionAsync(ParseResult parseResult, Boolean prerelease, String source, CancellationToken cancellationToken) in C:\git\aspire\src\Aspire.Cli\Commands\NewCommand.cs:line 131
   at Aspire.Cli.Commands.NewCommand.ExecuteAsync(ParseResult parseResult, CancellationToken cancellationToken) in C:\git\aspire\src\Aspire.Cli\Commands\NewCommand.cs:line 153
   at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions