microsoft/aspire · error · InvalidOperationException
The Microsoft Foundry model catalog response did not…
Error message
The Microsoft Foundry model catalog response did not contain an indexEntitiesResponse.value array. Response: {GetResponseSnippet(pageResponse)} What it means
GetAllModelsAsync pages the Foundry catalog and deserializes each page into ApiResponse, expecting an indexEntitiesResponse.value array. If the JSON lacks that array (null envelope or null Value), the tool cannot page the catalog and throws, including a truncated response snippet for diagnosis. This catches schema drift and non-catalog payloads early.
Solutions
- Read the response snippet in the exception message to see the actual payload shape and identify the mismatch.
- Update the ApiResponse/IndexEntitiesResponse DTOs to match the current Foundry API schema if fields were renamed or moved.
- Verify authentication and the catalog endpoint URL — HTML or error JSON instead of the catalog envelope usually means credentials or URL problems.
- Pin/adjust the requested Foundry API version so the response keeps the expected envelope.
Defensive patterns
Strategy: try-catch
Type guard
if (apiResponse?.IndexEntitiesResponse?.Value is not { } pageModels)
{
// handle missing envelope before consuming the array
return;
} Try / catch
try
{
await RunGenModelAsync();
}
catch (InvalidOperationException ex) when (ex.Message.Contains("indexEntitiesResponse.value"))
{
// schema drift or auth redirect: inspect snippet, update DTOs or credentials
} Prevention
- Keep ApiResponse DTOs in sync with the current Foundry API contract
- Pin the Foundry API version requested by ModelClient
- Validate credentials before long codegen runs
- Alert on non-catalog payloads (HTML/error JSON) with HTTP 200
When it happens
Trigger: The Foundry catalog endpoint returns JSON where indexEntitiesResponse or its value property is missing/null — e.g. an error page, auth redirect HTML, or an API schema change — during the paging loop in GetAllModelsAsync.
Common situations: Foundry API version update renaming indexEntitiesResponse.value; being redirected to a login page due to expired/missing credentials; hitting a wrong URL that returns JSON without the expected envelope; CDN/error responses with 200 status.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- Expected start of chat message object.
- Missing 'type' property.
- The configuration file
- The Microsoft Foundry model catalog response included…
- The Microsoft Foundry model catalog returned the same…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/02de831a676050de.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Foundry/tools/GenModel.cs:760
{
var allModels = new List<ModelEntity>();
string? continuationToken = null;
string? previousToken;
int pageCount = 0;
do
{
pageCount++;
Console.WriteLine($"\n=== Fetching page {pageCount} ===");
var pageResponse = await GetModelsAsync(continuationToken).ConfigureAwait(false);
var apiResponse = JsonSerializer.Deserialize<ApiResponse>(pageResponse);
if (apiResponse?.IndexEntitiesResponse?.Value is not { } pageModels)
{
throw new InvalidOperationException($"The Microsoft Foundry model catalog response did not contain an indexEntitiesResponse.value array. Response: {GetResponseSnippet(pageResponse)}");
}
ValidateSuccessfulCatalogResponse(apiResponse, pageResponse);
foreach (var model in pageModels)
{
allModels.Add(model);
}
Console.WriteLine($"Fetched page with {pageModels.Count} models. Total so far: {allModels.Count}");
// Check if there's a continuation token for the next page
previousToken = continuationToken;
continuationToken = apiResponse?.IndexEntitiesResponse?.ContinuationToken;
if (!string.IsNullOrEmpty(continuationToken))
{
Console.WriteLine($"Found continuation token for next page: {continuationToken.Substring(0, Math.Min(50, continuationToken.Length))}...");View on GitHub (pinned to 25830f84bd)