diff --git a/frontend/src/scenes/data-warehouse/external/forms/sourceFormLogic.ts b/frontend/src/scenes/data-warehouse/external/forms/sourceFormLogic.ts index b49520c71fa67..1bca52f3bffbf 100644 --- a/frontend/src/scenes/data-warehouse/external/forms/sourceFormLogic.ts +++ b/frontend/src/scenes/data-warehouse/external/forms/sourceFormLogic.ts @@ -84,6 +84,9 @@ export const sourceFormLogic = kea([ submitExternalDataSourceFailure: ({ error }) => { lemonToast.error(error?.message || 'Something went wrong') }, + submitDatabaseSchemaFormFailure: ({ error }) => { + lemonToast.error(error?.message || 'Something went wrong') + }, handleRedirect: async ({ kind, searchParams }) => { switch (kind) { case 'hubspot': { diff --git a/posthog/warehouse/api/external_data_source.py b/posthog/warehouse/api/external_data_source.py index 6078e9d8cd6da..faf884d6c8b3b 100644 --- a/posthog/warehouse/api/external_data_source.py +++ b/posthog/warehouse/api/external_data_source.py @@ -341,7 +341,15 @@ def database_schema(self, request: Request, *arg: Any, **kwargs: Any): data={"message": "Cannot use internal Postgres database"}, ) - result = get_postgres_schemas(host, port, database, user, password, schema) + try: + result = get_postgres_schemas(host, port, database, user, password, schema) + except Exception as e: + logger.exception("Could not fetch Postgres schemas", exc_info=e) + return Response( + status=status.HTTP_400_BAD_REQUEST, + data={"message": "Could not fetch Postgres schemas. Please check all connection details are valid."}, + ) + result_mapped_to_options = [{"table": row, "should_sync": False} for row in result] return Response(status=status.HTTP_200_OK, data=result_mapped_to_options)