From e318ec258c5d219055770a690e384e88b5f12246 Mon Sep 17 00:00:00 2001 From: Will Chen Date: Thu, 9 Oct 2025 13:29:56 -0700 Subject: [PATCH] Allow passthrough for provider schemas (#1487) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1472 > [!NOTE] > Switches `ProviderSettingSchema` union to `.passthrough()` variants to accept extra fields and avoid overlapping schema conflicts. > > - **Schemas**: > - **`src/lib/schemas.ts`**: Update `ProviderSettingSchema` to use `.passthrough()` on `AzureProviderSettingSchema`, `VertexProviderSettingSchema`, and `RegularProviderSettingSchema` so unknown fields are preserved and overlapping required fields don’t cause mis-matches. > > Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7afa4b83d713b9eb433d4cce28c7fee73cd7545b. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot). --- src/lib/schemas.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/schemas.ts b/src/lib/schemas.ts index a1897a6..67178ae 100644 --- a/src/lib/schemas.ts +++ b/src/lib/schemas.ts @@ -114,9 +114,16 @@ export const VertexProviderSettingSchema = z.object({ export const ProviderSettingSchema = z.union([ // Must use more specific type first! // Zod uses the first type that matches. - AzureProviderSettingSchema, - VertexProviderSettingSchema, - RegularProviderSettingSchema, + // + // We use passthrough as a hack because Azure and Vertex + // will match together since their required fields overlap. + // + // In addition, there may be future provider settings that + // we may want to preserve (e.g. user downgrades to older version) + // so doing passthrough keeps these extra fields. + AzureProviderSettingSchema.passthrough(), + VertexProviderSettingSchema.passthrough(), + RegularProviderSettingSchema.passthrough(), ]); /**