Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Invalid Segment base URLs #4727

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading