Repository: supabase/supabase
File: apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorTableSheet.tsx (TypeScript)

Code before:
        projectRef: project.ref,
        bucketName: bucketName,
        indexName: values.name,
        dataType: 'float32',
        dimension: values.dimension!,
        distanceMetric: values.distanceMetric,
        metadataKeys: values.metadataKeys.map((key) => key.value),
      })
    } catch (error: any) {
      toast.error(`Failed to create vector table: ${error.message}`)
      return
    }

    try {
      if (wrapperInstance) {
        await importForeignSchema({
          projectRef: project.ref,
          connectionString: project?.connectionString,
          serverName: wrapperInstance.server_name,
          sourceSchema: getVectorBucketFDWSchemaName(bucketName),
          targetSchema: getVectorBucketFDWSchemaName(bucketName),
          schemaOptions: [`bucket_name '${bucketName}'`],
        })
      }
    } catch (error: any) {
      toast.warning(`Failed to connect vector table to the database: ${error.message}`)
    }

    toast.success(`Successfully created vector table “${values.name}”`)
    form.reset()

    setVisible(false)
  }

  useEffect(() => {
    if (!visible) {
      form.reset()
    }
  }, [visible])

  return (
    <Sheet open={visible} onOpenChange={setVisible}>
      <SheetTrigger asChild>
        <ButtonTooltip
          block
          size="tiny"
          type="primary"
          className="w-fit"
          icon={<Plus size={14} />}
          disabled={!canCreateBuckets}
          onClick={() => setVisible(true)}

Review comment (suggestion):
Changes related to removing bucket name as a field. From what I can see, bucket name is still required upon table creation. If it’s missing, it’s likely a loading state issue, not a user error.

Code after:
    if (!bucketName) return

    try {
      await createVectorBucketTable({
        projectRef: project.ref,
        bucketName: bucketName,
        indexName: values.name,
        dataType: 'float32',
        dimension: values.dimension!,
        distanceMetric: values.distanceMetric,
        metadataKeys: values.metadataKeys.map((key) => key.value),
      })
    } catch (error: any) {
      toast.error(`Failed to create vector table: ${error.message}`)
      return
    }

    try {
      if (wrapperInstance) {
        await importForeignSchema({
          projectRef: project.ref,
          connectionString: project?.connectionString,
          serverName: wrapperInstance.server_name,
          sourceSchema: getVectorBucketFDWSchemaName(bucketName),
          targetSchema: getVectorBucketFDWSchemaName(bucketName),
          schemaOptions: [`bucket_name '${bucketName}'`],
        })
      }
    } catch (error: any) {
      toast.warning(`Failed to connect vector table to the database: ${error.message}`)
    }

    toast.success(`Successfully created vector table “${values.name}”`)
    form.reset()

    setVisible(false)
  }

  useEffect(() => {
    if (!visible) {
      form.reset()
    }
  }, [visible])

  return (
    <Sheet open={visible} onOpenChange={setVisible}>
      <SheetTrigger asChild>
        <ButtonTooltip
          block
          size="tiny"
          type="primary"