From 56e7a4c46990ad9c712501c1bf4b059f42f9b462 Mon Sep 17 00:00:00 2001 From: Eric Duong Date: Thu, 27 Jun 2024 16:03:07 -0400 Subject: [PATCH] fix(data-warehouse): return empty incremental field list (#23287) * return empty and not an error * Update query snapshots * Update query snapshots * Update query snapshots * Update query snapshots --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- posthog/warehouse/api/external_data_schema.py | 9 ++------- posthog/warehouse/api/test/test_external_data_schema.py | 4 +++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/posthog/warehouse/api/external_data_schema.py b/posthog/warehouse/api/external_data_schema.py index 35669885f66..dff4252b34a 100644 --- a/posthog/warehouse/api/external_data_schema.py +++ b/posthog/warehouse/api/external_data_schema.py @@ -317,17 +317,12 @@ class ExternalDataSchemaViewset(TeamAndOrgViewSetMixin, viewsets.ModelViewSet): ] else: mapping = PIPELINE_TYPE_INCREMENTAL_FIELDS_MAPPING.get(source.source_type) - if not mapping: + if mapping is None: return Response( status=status.HTTP_400_BAD_REQUEST, data={"message": f'Source type "{source.source_type}" not found'}, ) - mapping_fields = mapping.get(instance.name) - if not mapping_fields: - return Response( - status=status.HTTP_400_BAD_REQUEST, - data={"message": f'Incremental fields for "{source.source_type}.{instance.name}" can\'t be found'}, - ) + mapping_fields = mapping.get(instance.name, []) incremental_columns = mapping_fields diff --git a/posthog/warehouse/api/test/test_external_data_schema.py b/posthog/warehouse/api/test/test_external_data_schema.py index 4babec0833a..e248204d880 100644 --- a/posthog/warehouse/api/test/test_external_data_schema.py +++ b/posthog/warehouse/api/test/test_external_data_schema.py @@ -106,7 +106,9 @@ class TestExternalDataSchema(APIBaseTest): f"/api/projects/{self.team.pk}/external_data_schemas/{schema.id}/incremental_fields", ) - assert response.status_code == 400 + # should respond but with empty list. Example: Hubspot has not incremental fields but the response should be an empty list so that full refresh is selectable + assert response.status_code == 200 + assert response.json() == [] @pytest.mark.django_db(transaction=True) @pytest.mark.asyncio