Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Update FDW type for server_options to be nullable and fix TS issues (#41811)

Joshen Limb867dd73bb40
diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/WrapperRow.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/WrapperRow.tsx
index 43d6b8d200c..e31881d1752 100644
--- a/apps/studio/components/interfaces/Integrations/Wrappers/WrapperRow.tsx
+++ b/apps/studio/components/interfaces/Integrations/Wrappers/WrapperRow.tsx
@@ -21,7 +21,7 @@ import {
import { INTEGRATIONS } from '../Landing/Integrations.constants'
import DeleteWrapperModal from './DeleteWrapperModal'
import { EditWrapperSheet } from './EditWrapperSheet'
-import { formatWrapperTables } from './Wrappers.utils'
+import { convertKVStringArrayToJson, formatWrapperTables } from './Wrappers.utils'
interface WrapperRowProps {
wrapper: FDW
@@ -55,9 +55,7 @@ export const WrapperRow = ({
return <p className="text-foreground-lighter text-sm">A wrapper with this ID does not exist</p>
}
- const serverOptions = Object.fromEntries(
- wrapper.server_options.map((option) => option.split('='))
- )
+ const serverOptions = convertKVStringArrayToJson(wrapper.server_options ?? [])
const [encryptedMetadata, visibleMetadata] = partition(
integration?.meta?.server.options.filter((option) => !option.hidden),
'secureEntry'
diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorTableSheet.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorTableSheet.tsx
index 77b41165fa7..a89ac161897 100644
--- a/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorTableSheet.tsx
+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorTableSheet.tsx
@@ -111,7 +111,7 @@ export const CreateVectorTableSheet = ({ bucketName }: CreateVectorTableSheetPro
const { can: canCreateBuckets } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*')
const { data: wrapperInstance } = useS3VectorsWrapperInstance({ bucketId: bucketName })
- const schema = wrapperInstance?.server_options
+ const schema = (wrapperInstance?.server_options ?? [])
.find((x) => x.startsWith('supabase_target_schema'))
?.split('supabase_target_schema=')[1]
diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails/index.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails/index.tsx
index ac3ca1c4bcb..9388f689dfd 100644
--- a/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails/index.tsx
+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails/index.tsx
@@ -104,7 +104,7 @@ export const VectorBucketDetails = () => {
} = useS3VectorsWrapperInstance({ bucketId })
const isLoading = isLoadingIndexes || isLoadingWrapper
- const hasSetUpForeignSchema = wrapperInstance?.server_options.find((x) =>
+ const hasSetUpForeignSchema = (wrapperInstance?.server_options ?? []).find((x) =>
x.startsWith('supabase_target_schema')
)
diff --git a/apps/studio/data/fdw/fdws-query.ts b/apps/studio/data/fdw/fdws-query.ts
index 9b7f249341f..19a41f1675b 100644
--- a/apps/studio/data/fdw/fdws-query.ts
+++ b/apps/studio/data/fdw/fdws-query.ts
@@ -60,7 +60,7 @@ export type FDW = {
name: string
handler: string
server_name: string
- server_options: string[]
+ server_options: string[] | null
tables: FDWTable[]
}
diff --git a/apps/studio/hooks/useProtectedSchemas.ts b/apps/studio/hooks/useProtectedSchemas.ts
index 1fb9e04d66b..1bd1271be31 100644
--- a/apps/studio/hooks/useProtectedSchemas.ts
+++ b/apps/studio/hooks/useProtectedSchemas.ts
@@ -64,7 +64,7 @@ const useFdwSchemasQuery = () => {
const fdwSchemas = icebergFDWs.map((fdw) => {
const schemaOption =
- convertKVStringArrayToJson(fdw.server_options)['supabase_target_schema'] ?? ''
+ convertKVStringArrayToJson(fdw.server_options ?? [])['supabase_target_schema'] ?? ''
const schemas = uniq(schemaOption.split(',').filter(Boolean))