Skip to content

Commit

Permalink
fix: Invalid Segment base URLs (#4727)
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 authored Oct 15, 2024
1 parent d76a6f0 commit 8b823a7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/integrations/segment/constants.py
Original file line number Diff line number Diff line change
@@ -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/"
Original file line number Diff line number Diff line change
@@ -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),
]
2 changes: 1 addition & 1 deletion api/integrations/segment/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SegmentConfigurationSerializer(BaseEnvironmentIntegrationModelSerializer):
constants.DUBLIN_BASE_URL,
],
required=False,
default="api.segment.io/",
default=constants.DEFAULT_BASE_URL,
)

class Meta:
Expand Down
2 changes: 1 addition & 1 deletion api/tests/unit/integrations/segment/test_unit_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8b823a7

Please sign in to comment.