Skip to content

Commit 95202a8

Browse files
committed
fix(providers): normalize vertex location case before validating
Hostnames are case-insensitive, so a mixed-case location like US-Central1 reaches Google today. Lowercase it before the region check rather than rejecting an input that currently works.
1 parent e0e7fb7 commit 95202a8

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

apps/sim/providers/vertex/index.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ describe('vertexProvider location and project validation', () => {
9191
expect(mockExecuteGeminiRequest).toHaveBeenCalledTimes(1)
9292
})
9393

94+
it('normalizes a mixed-case location rather than rejecting it', async () => {
95+
await vertexProvider.executeRequest(request({ vertexLocation: 'US-Central1' }))
96+
97+
expect(genAIArgs[0]).toMatchObject({ location: 'us-central1' })
98+
})
99+
94100
it('defaults to us-central1 when no location is supplied', async () => {
95101
await vertexProvider.executeRequest(request())
96102

apps/sim/providers/vertex/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ export const vertexProvider: ProviderConfig = {
3535
request: ProviderRequest
3636
): Promise<ProviderResponse | StreamingExecution> => {
3737
const vertexProject = request.vertexProject || env.VERTEX_PROJECT
38-
const vertexLocation = request.vertexLocation || env.VERTEX_LOCATION || 'us-central1'
38+
// Hostnames are case-insensitive, so a mixed-case location reaches Google fine
39+
// today. Normalize before validating rather than rejecting it as malformed.
40+
const vertexLocation = (
41+
request.vertexLocation ||
42+
env.VERTEX_LOCATION ||
43+
'us-central1'
44+
).toLowerCase()
3945

4046
if (!vertexProject) {
4147
throw new Error(

0 commit comments

Comments
 (0)