From 581923e112ec51363e825a3d55f6270460cce2d1 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Tue, 15 Oct 2024 10:17:16 +0100 Subject: [PATCH 1/3] fix: Invalid Segment base URLs --- api/integrations/segment/constants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/integrations/segment/constants.py b/api/integrations/segment/constants.py index dd62da9089b5..6e5f138e2f13 100644 --- a/api/integrations/segment/constants.py +++ b/api/integrations/segment/constants.py @@ -1,2 +1,2 @@ -DEFAULT_BASE_URL = "api.segment.io/" -DUBLIN_BASE_URL = "events.eu1.segmentapis.com/" +DEFAULT_BASE_URL = "https://api.segment.io/" +DUBLIN_BASE_URL = "https://events.eu1.segmentapis.com/" From ea5850b09e3e07ddd5251eb525d7137580cbb103 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Tue, 15 Oct 2024 10:20:08 +0100 Subject: [PATCH 2/3] add migration --- .../0006_set_base_url_to_default_again.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 api/integrations/segment/migrations/0006_set_base_url_to_default_again.py diff --git a/api/integrations/segment/migrations/0006_set_base_url_to_default_again.py b/api/integrations/segment/migrations/0006_set_base_url_to_default_again.py new file mode 100644 index 000000000000..6576a65e4da5 --- /dev/null +++ b/api/integrations/segment/migrations/0006_set_base_url_to_default_again.py @@ -0,0 +1,28 @@ +# TODO: squash 0005 and this migration together + +from django.apps.registry import Apps +from django.db import migrations +from django.db.backends.base.schema import BaseDatabaseSchemaEditor + +from integrations.segment import constants + + +_INVALID_DEFAULT_BASE_URL = "api.segment.io/" + + +def set_base_url(apps: Apps, schema_editor: BaseDatabaseSchemaEditor) -> None: + SegmentConfiguration = apps.get_model("segment", "SegmentConfiguration") + SegmentConfiguration.objects.filter(base_url=_INVALID_DEFAULT_BASE_URL).update( + base_url=constants.DEFAULT_BASE_URL, + ) + + +class Migration(migrations.Migration): + + dependencies = [ + ("segment", "0005_set_base_url_to_default"), + ] + + operations = [ + migrations.RunPython(set_base_url, reverse_code=migrations.RunPython.noop), + ] From e6f6c35579c9c76d1cc82abda342f3ba36072748 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Tue, 15 Oct 2024 10:41:23 +0100 Subject: [PATCH 3/3] fix default, test --- api/integrations/segment/serializers.py | 2 +- api/tests/unit/integrations/segment/test_unit_segment.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/integrations/segment/serializers.py b/api/integrations/segment/serializers.py index 95357c6eab28..edc67c2c8efc 100644 --- a/api/integrations/segment/serializers.py +++ b/api/integrations/segment/serializers.py @@ -15,7 +15,7 @@ class SegmentConfigurationSerializer(BaseEnvironmentIntegrationModelSerializer): constants.DUBLIN_BASE_URL, ], required=False, - default="api.segment.io/", + default=constants.DEFAULT_BASE_URL, ) class Meta: diff --git a/api/tests/unit/integrations/segment/test_unit_segment.py b/api/tests/unit/integrations/segment/test_unit_segment.py index 517d72d4732c..9548e06c0daa 100644 --- a/api/tests/unit/integrations/segment/test_unit_segment.py +++ b/api/tests/unit/integrations/segment/test_unit_segment.py @@ -10,7 +10,7 @@ def test_segment_initialized_correctly(): # Given api_key = "123key" - base_url = "api.segment.io/" + base_url = "https://api.segment.io/" config = SegmentConfiguration(api_key=api_key, base_url=base_url) # When