Skip to content

Commit 276cb03

Browse files
committed
fix: use explicit azureOpenAiDefaultApiVersion fallback when apiVersion is empty
Addresses review feedback: the UI placeholder shows '2025-04-01-preview' via azureOpenAiDefaultApiVersion, so the handler should use the same constant as fallback instead of silently deferring to the SDK's internal default.
1 parent 2a5e42e commit 276cb03

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/api/providers/__tests__/azure.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describe("AzureHandler", () => {
8181
})
8282
expect(handlerWithoutVersion).toBeInstanceOf(AzureHandler)
8383
expect(mockCreateAzure).toHaveBeenLastCalledWith(
84-
expect.not.objectContaining({ apiVersion: expect.anything() }),
84+
expect.objectContaining({ apiVersion: "2025-04-01-preview" }),
8585
)
8686
})
8787

@@ -98,14 +98,14 @@ describe("AzureHandler", () => {
9898
)
9999
})
100100

101-
it("should omit API version when configured value is blank", () => {
101+
it("should use default API version when configured value is blank", () => {
102102
new AzureHandler({
103103
...mockOptions,
104104
azureApiVersion: " ",
105105
})
106106

107107
expect(mockCreateAzure).toHaveBeenLastCalledWith(
108-
expect.not.objectContaining({ apiVersion: expect.anything() }),
108+
expect.objectContaining({ apiVersion: "2025-04-01-preview" }),
109109
)
110110
})
111111
})

src/api/providers/azure.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Anthropic } from "@anthropic-ai/sdk"
22
import { createAzure } from "@ai-sdk/azure"
33
import { streamText, generateText, ToolSet } from "ai"
44

5-
import { azureModels, azureDefaultModelInfo, type ModelInfo } from "@roo-code/types"
5+
import { azureModels, azureDefaultModelInfo, azureOpenAiDefaultApiVersion, type ModelInfo } from "@roo-code/types"
66

77
import type { ApiHandlerOptions } from "../../shared/api"
88

@@ -46,7 +46,7 @@ export class AzureHandler extends BaseProvider implements SingleCompletionHandle
4646
this.provider = createAzure({
4747
resourceName: options.azureResourceName ?? "",
4848
apiKey: options.azureApiKey, // Optional — Azure supports managed identity / Entra ID auth
49-
...(apiVersion ? { apiVersion } : {}),
49+
...(apiVersion ? { apiVersion } : { apiVersion: azureOpenAiDefaultApiVersion }),
5050
headers: DEFAULT_HEADERS,
5151
})
5252
}

0 commit comments

Comments
 (0)