mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-12 02:02:13 +03:00
fix(types): validate Azure OpenAI base URLs (#9563)
Merge-train validated (tip 6ce4effef8). Vitest failures confirmed as base-red (#9679).
This commit is contained in:
@@ -28,7 +28,11 @@ export class AzureOpenAIExecutor extends DefaultExecutor {
|
||||
void urlIndex;
|
||||
|
||||
const providerSpecificData = credentials?.providerSpecificData || {};
|
||||
const baseUrl = normalizeAzureBaseUrl(providerSpecificData.baseUrl || this.config.baseUrl);
|
||||
const baseUrl = normalizeAzureBaseUrl(
|
||||
typeof providerSpecificData.baseUrl === "string"
|
||||
? providerSpecificData.baseUrl
|
||||
: this.config.baseUrl
|
||||
);
|
||||
const apiVersion =
|
||||
typeof providerSpecificData.apiVersion === "string" && providerSpecificData.apiVersion.trim()
|
||||
? providerSpecificData.apiVersion.trim()
|
||||
|
||||
@@ -32,6 +32,22 @@ test("AzureOpenAIExecutor strips duplicated /openai suffixes from configured bas
|
||||
);
|
||||
});
|
||||
|
||||
test("AzureOpenAIExecutor ignores non-string credential base URLs", () => {
|
||||
const executor = new AzureOpenAIExecutor();
|
||||
executor.config.baseUrl = "https://fallback-resource.openai.azure.com";
|
||||
|
||||
const url = executor.buildUrl("deploy-1", false, 0, {
|
||||
providerSpecificData: {
|
||||
baseUrl: { host: "untrusted.example.com" },
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
url,
|
||||
"https://fallback-resource.openai.azure.com/openai/deployments/deploy-1/chat/completions?api-version=2024-12-01-preview"
|
||||
);
|
||||
});
|
||||
|
||||
test("AzureOpenAIExecutor uses api-key auth headers instead of Bearer auth", () => {
|
||||
const executor = new AzureOpenAIExecutor();
|
||||
const headers = executor.buildHeaders({ apiKey: "azure-key-123" }, true);
|
||||
|
||||
Reference in New Issue
Block a user