microsoft / microsoft/foundry-dev-tools

JSON deserialization failure when loading model catalog (empty response body)

Open
#404 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs attention
Dominant language
JavaScript
Stars
2.1k
Forks
260
Avg merge
42m
Merged PRs (30d)
29

Description

Description

When the Foundry Toolkit loads the model catalog, one or more models fail to deserialize
with a JSON parse error indicating an empty response body. The error repeats multiple times
per session (appears to be triggered once per concurrent service instance), but the extension
recovers and loads the remaining models successfully.

  • Extension version: 1.4.0
  • Component: Microsoft.Neutron.AzureFoundry
  • Platform: Windows 11

Error

Failed to process model #0 on page 1. error: [The input does not contain any JSON tokens.
Expected the input to start with a valid JSON token, when isFinalBlock is true.
Path: $ | LineNumber: 0 | BytePositionInLine: 0.

at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack&, JsonReaderException)
at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader&, T&, JsonSerializerOptions, ReadStack&)    at System.Text.Json.JsonSerializer.Deserialize[TValue](String, JsonTypeInfo1)
at Microsoft.Neutron.AzureFoundry.LocalModelHelper.ToAzureFoundryLocalModel(LocalModel)
at Microsoft.Neutron.AzureFoundry.AzureFoundryApiService.CreateModelsFromResponse(LocalModel[], Int32)

A separate warning is also logged for the same session:

Model Phi-4-reasoning-generic-gpu:1 does not have a valid prompt template.

Observed behavior

ToAzureFoundryLocalModel receives an empty or non-JSON string for at least one model entry (model #0, page 1) and throws before any tokens can be read.
The error fires multiple times simultaneously, suggesting the fetch is parallelized and all concurrent calls hit the same bad entry.
The extension recovers: 82 models are ultimately loaded and Phi Silica reports as ready.
Expected behavior
The bad model entry should be skipped with a single warning rather than throwing a hard exception multiple times.
ToAzureFoundryLocalModel (or its caller) should guard against null/empty/non-JSON input and surface a descriptive warning instead of a stack trace.
Root cause hypothesis
LocalModelHelper.ToAzureFoundryLocalModel calls JsonSerializer.Deserialize on a string
that is empty or whitespace (possibly from an API response with no body, an HTTP 204, or a
network blip). There is no null/empty guard before deserialization.

Steps to reproduce
  1. Open VS Code with the Windows AI Studio extension (v1.4.0).
  2. Open the Foundry Toolkit panel.
  3. Observe the extension output log — the JSON errors appear during the initial model catalog fetch.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with LocalModelHelper.ToAzureFoundryLocalModel and its caller, AzureFoundryApiService.CreateModelsFromResponse, then reproduce the model catalog fetch from the Foundry Toolkit panel and inspect the output log. Done means empty or invalid model responses are skipped with one descriptive warning, without repeated JSON stack traces, while the remaining models still load.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.