{"record":{"id":"46af77d679f9e456","repo":"microsoft/aspire","slug":"microsoft-foundry-model-catalog-request-failed-with-http-int","errorCode":null,"errorMessage":"Microsoft Foundry model catalog request failed with HTTP {(int)response.StatusCode} ({response.StatusCode}). Response: {GetResponseSnippet(content)}","messagePattern":"Microsoft Foundry model catalog request failed with HTTP (.+?) \\((.+?)\\)\\. Response: (.+?)","errorType":"http","errorClass":"HttpRequestException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Foundry/tools/GenModel.cs","lineNumber":952,"sourceCode":"                        await Task.Delay(partialDelay).ConfigureAwait(false);\n                        continue;\n                    }\n\n                    throw new InvalidOperationException($\"The Microsoft Foundry model catalog response included partial failure data in {string.Join(\", \", partialFailureFields)}. Refusing to overwrite the generated model descriptors with a partial catalog. Response: {GetResponseSnippet(content)}\");\n                }\n\n                return content;\n            }\n\n            if (IsTransientStatusCode(response.StatusCode) && attempt < MaxRequestAttempts)\n            {\n                var delay = GetRetryDelay(response, content, attempt);\n                Console.WriteLine($\"Microsoft Foundry model catalog request failed with HTTP {(int)response.StatusCode} ({response.StatusCode}). Retrying in {delay.TotalSeconds:N0}s (attempt {attempt + 1}/{MaxRequestAttempts}).\");\n                await Task.Delay(delay).ConfigureAwait(false);\n                continue;\n            }\n\n            throw new HttpRequestException($\"Microsoft Foundry model catalog request failed with HTTP {(int)response.StatusCode} ({response.StatusCode}). Response: {GetResponseSnippet(content)}\", inner: null, response.StatusCode);\n        }\n\n        throw new InvalidOperationException(\"The Microsoft Foundry model catalog request loop completed without returning or throwing.\");\n    }\n\n    public void Dispose()\n    {\n        _httpClient?.Dispose();\n        _handler?.Dispose();\n    }\n\n    private void RunFixups(List<ModelEntity> allModels)\n    {\n        if (_isFoundryLocal)\n        {\n            // Exclude models that are not listed by foundry local (TBD)\n            // c.f. https://github.com/microsoft/Foundry-Local/issues/245#issuecomment-3404022929\n            allModels.RemoveAll(m => m.Annotations?.Tags?.TryGetValue(\"alias\", out var alias) is true && alias is not null &&","sourceCodeStart":934,"sourceCodeEnd":970,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Foundry/tools/GenModel.cs#L934-L970","documentation":"GetModelsAsync throws HttpRequestException when the Foundry catalog endpoint returns a non-transient (or retry-exhausted) HTTP error status, embedding the status code and a truncated response body. It lets callers see both the HTTP failure and the server's error payload.","triggerScenarios":"Any call to ModelClient.GetModelsAsync (via GetAllModelsAsync) where the HTTP response status code is an error status that is not retriable, or where retries of transient statuses were exhausted (attempt >= MaxRequestAttempts).","commonSituations":"Expired or missing Azure credentials (401/403); wrong catalog endpoint URL (404); service outage (5xx after retries); throttling that outlasted the retry budget (429); corporate proxy blocking the request.","solutions":["Check the HTTP status in the message: fix authentication (az login / correct token) for 401/403.","Verify the catalog endpoint URL and API version for 404/400 responses.","For 429/5xx, wait and re-run — the built-in retry already applied several attempts.","Inspect the response snippet for a server-side error message identifying the root cause.","Ensure network/proxy settings allow the request to reach the Foundry endpoint."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    await RunGenModelAsync();\n}\ncatch (HttpRequestException ex)\n{\n    Console.WriteLine($\"Catalog fetch failed: {ex.StatusCode}. Check credentials/endpoint and retry.\");\n}","preventionTips":["Refresh Azure credentials before codegen runs (az login)","Verify the catalog endpoint URL and API version","Expect 429 throttling and keep the retry budget generous","Ensure corporate proxies allow the Foundry endpoints"],"tags":["http","http-error-response","azure-foundry","authentication"],"backgroundTag":"http-error-response","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}