{"record":{"id":"fbf7d3cb2ec2aa3f","repo":"JuliusBrussee/caveman","slug":"azure-foundry-api-version-q-is-not-supported","errorCode":null,"errorMessage":"azure Foundry api-version %q is not supported","messagePattern":"azure Foundry api-version %q is not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/providers/azureopenai/azure_routing.go","lineNumber":45,"sourceCode":"}\n\n// ResolveUpstreamURL validates either the legacy deployment route or the\n// current Foundry Models v1 inference route before resolving upstream.\nfunc (a Adapter) ResolveUpstreamURL(ctx context.Context, req *http.Request, route providers.RouteContext) (*url.URL, error) {\n\tif err := validateAzureRequest(req.URL); err != nil {\n\t\treturn nil, err\n\t}\n\treturn a.Base.ResolveUpstreamURL(ctx, req, route)\n}\n\nfunc validateAzureRequest(u *url.URL) error {\n\tif foundryV1InferenceRoute(u.Path) {\n\t\tversions := u.Query()[\"api-version\"]\n\t\tif len(versions) > 1 {\n\t\t\treturn fmt.Errorf(\"azure request has duplicate api-version values\")\n\t\t}\n\t\tif len(versions) == 1 && versions[0] != \"v1\" && versions[0] != \"preview\" {\n\t\t\treturn fmt.Errorf(\"azure Foundry api-version %q is not supported\", versions[0])\n\t\t}\n\t\treturn nil\n\t}\n\tif !legacyChatCompletionsRoute(u.Path) {\n\t\treturn fmt.Errorf(\"azure legacy inference path %q is not supported\", u.Path)\n\t}\n\tversions := u.Query()[\"api-version\"]\n\tif len(versions) > 1 {\n\t\treturn fmt.Errorf(\"azure request has duplicate api-version values\")\n\t}\n\tversion := \"\"\n\tif len(versions) == 1 {\n\t\tversion = versions[0]\n\t}\n\tif version == \"\" {\n\t\treturn fmt.Errorf(\"azure request missing api-version\")\n\t}\n\tif !apiVersionAllowed(version) {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/providers/azureopenai/azure_routing.go#L27-L63","documentation":"The Azure OpenAI adapter only accepts the Foundry Models v1 inference route with api-version=v1 or api-version=preview. A request to /openai/v1/chat/completions or /openai/v1/responses carrying any other api-version value is rejected before reaching upstream. This pins Foundry v1 requests to the two documented version strings instead of date-style api-versions.","triggerScenarios":"A request to the Foundry v1 route (/azure/openai/v1/chat/completions or /azure/openai/v1/responses) whose query string contains exactly one api-version parameter whose value is neither \"v1\" nor \"preview\", e.g. ?api-version=2024-10-21.","commonSituations":"Clients that reuse the date-style api-version from legacy deployment URLs on the new Foundry v1 endpoint; SDK version switches that emit a pinned date version; copy-pasting an example URL from legacy Azure docs into a v1 route.","solutions":["Set api-version=v1 (or api-version=preview) in the query string of Foundry v1 route requests.","Remove the api-version query parameter entirely — the Foundry v1 route allows it to be absent.","If a date-style version is required, use the legacy deployment route /azure/openai/deployments/{deployment}/chat/completions instead, where the allowlist applies."],"exampleFix":"// before\nGET /azure/openai/v1/chat/completions?api-version=2024-10-21\n// after\nGET /azure/openai/v1/chat/completions?api-version=v1","handlingStrategy":"validation","validationCode":"func foundryVersionOK(rawURL string) bool {\n\tu, err := url.Parse(rawURL)\n\tif err != nil {\n\t\treturn false\n\t}\n\tp := strings.TrimPrefix(u.Path, \"/azure\")\n\tif p != \"/openai/v1/chat/completions\" && p != \"/openai/v1/responses\" {\n\t\treturn true\n\t}\n\tvs := u.Query()[\"api-version\"]\n\treturn len(vs) <= 1 && (len(vs) == 0 || vs[0] == \"v1\" || vs[0] == \"preview\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never attach date-style api-version values to Foundry v1 route URLs.","Build query strings with url.Values so parameters cannot silently duplicate or carry stale values.","Keep one canonical client constant for the v1 api-version (\"v1\" or \"preview\")."],"tags":["azure","openai","api-version","routing","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}