From dbfa35ddb3bd916cc42c43603fc3ce26277bf717 Mon Sep 17 00:00:00 2001 From: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Thu, 8 Oct 2026 17:25:44 +0200 Subject: [PATCH] fix(studio): remove unsupported log drain form variants (#51449) ## Problem The log drain form still includes Postgres, ClickHouse, and BigQuery placeholder variants even though the dashboard does not offer these destinations. Production Platform API create/update types now exclude them, causing Studio type errors when the API declarations are regenerated. ## Fix Remove the unused variants from the form and submission schemas. Accept the broader response type for incoming defaults, resolve defaults through the selectable destination list, and use the form schema type for the selector. ## How to test - Run `pnpm --filter studio typecheck` with committed API types and with types generated from production. Both should pass. - Run Prettier and ESLint on `LogDrainDestinationSheetForm.tsx`. - Open project or organization audit log drain settings and add a supported destination. Available destinations remain unchanged. Validation: Studio typecheck passes with both committed API types and freshly generated production API types. Prettier passes; ESLint reports only existing warnings. Generated declarations are not included in this PR. --- .../LogDrainDestinationSheetForm.tsx | 39 ++++++------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/apps/studio/components/interfaces/LogDrains/LogDrainDestinationSheetForm.tsx b/apps/studio/components/interfaces/LogDrains/LogDrainDestinationSheetForm.tsx index 0fdbf8eab0f..d5015ecec63 100644 --- a/apps/studio/components/interfaces/LogDrains/LogDrainDestinationSheetForm.tsx +++ b/apps/studio/components/interfaces/LogDrains/LogDrainDestinationSheetForm.tsx @@ -111,18 +111,6 @@ const lokiSubmitSchema = z.object({ headers: headerRecordSchema, }) -const postgresSchema = z.object({ - type: z.literal('postgres'), -}) - -const bigquerySchema = z.object({ - type: z.literal('bigquery'), -}) - -const clickhouseSchema = z.object({ - type: z.literal('clickhouse'), -}) - const s3Schema = z.object({ type: z.literal('s3'), s3_bucket: z.string().min(1, { message: 'Bucket name is required' }), @@ -197,9 +185,6 @@ const formUnion = z.discriminatedUnion('type', [ webhookFormSchema, datadogSchema, lokiFormSchema, - postgresSchema, - bigquerySchema, - clickhouseSchema, s3Schema, sentrySchema, axiomSchema, @@ -212,9 +197,6 @@ const submitUnion = z.discriminatedUnion('type', [ webhookSubmitSchema, datadogSchema, lokiSubmitSchema, - postgresSchema, - bigquerySchema, - clickhouseSchema, s3Schema, sentrySchema, axiomSchema, @@ -314,7 +296,7 @@ function LogDrainFormItem({ ) } -type DefaultValues = { type: LogDrainType } & Partial +type DefaultValues = Partial export function LogDrainDestinationSheetForm({ open, @@ -339,14 +321,14 @@ export function LogDrainDestinationSheetForm({ // it produces a correct union type of all possible configs. Unfortunately, this type was not designed correctly // and it does not include `type` inside the config itself, so it's not trivial to create `discriminatedUnion` // out of it, therefore for an ease of use now, we bail to `any` until the better time come. - const defaultType = defaultValues?.type || 'webhook' + const defaultType = + LOG_DRAIN_TYPES.find(({ value }) => value === defaultValues?.type)?.value || 'webhook' const defaultHeaderEntries = useMemo(() => { const config = (defaultValues?.config || {}) as any - const type = defaultValues?.type || 'webhook' return headerRecordToRows( - mode === 'create' ? getDefaultHeadersByType(type) : config?.headers || {} + mode === 'create' ? getDefaultHeadersByType(defaultType) : config?.headers || {} ) - }, [defaultValues, mode]) + }, [defaultValues, mode, defaultType]) const enabledLogDrainTypes = useEnabledLogDrainTypes() @@ -354,11 +336,10 @@ export function LogDrainDestinationSheetForm({ const formValues = useMemo(() => { const config = (defaultValues?.config || {}) as any - const type = defaultValues?.type || 'webhook' return { name: defaultValues?.name || '', description: defaultValues?.description || '', - type, + type: defaultType, http: config?.http || 'http2', gzip: mode === 'create' ? true : config?.gzip || false, headerEntries: defaultHeaderEntries, @@ -386,7 +367,7 @@ export function LogDrainDestinationSheetForm({ client_cert: config?.client_cert || '', client_key: config?.client_key || '', } - }, [defaultValues, mode, defaultHeaderEntries]) + }, [defaultValues, mode, defaultHeaderEntries, defaultType]) const form = useForm({ resolver: zodResolver(formSchema), @@ -458,8 +439,10 @@ export function LogDrainDestinationSheetForm({ >