Skip to content

Commit c4dc41d

Browse files
ref: upgrade to django 5.0 (#64360)
<!-- Describe your PR here. -->
1 parent eb5765a commit c4dc41d

File tree

10 files changed

+18
-37
lines changed

10 files changed

+18
-37
lines changed

requirements-base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ datadog>=0.44
1313
django-crispy-forms>=1.14.0
1414
django-csp>=3.7
1515
django-pg-zero-downtime-migrations>=0.13
16-
Django>=4.2.8,<5
16+
Django>=5,<6
1717
djangorestframework>=3.14.0
1818
drf-spectacular>=0.26.3
1919
email-reply-parser>=0.5.12

requirements-dev-frozen.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ cssutils==2.9.0
3939
datadog==0.44.0
4040
distlib==0.3.4
4141
distro==1.8.0
42-
django==4.2.8
42+
django==5.0.1
4343
django-crispy-forms==1.14.0
4444
django-csp==3.7
4545
django-pg-zero-downtime-migrations==0.13

requirements-frozen.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ cssselect==1.0.3
3232
cssutils==2.9.0
3333
datadog==0.44.0
3434
distro==1.8.0
35-
django==4.2.8
35+
django==5.0.1
3636
django-crispy-forms==1.14.0
3737
django-csp==3.7
3838
django-pg-zero-downtime-migrations==0.13

src/sentry/auth/providers/saml2/forms.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def process_xml(form):
4343

4444

4545
class URLMetadataForm(forms.Form):
46-
metadata_url = forms.URLField(label="Metadata URL")
46+
metadata_url = forms.URLField(label="Metadata URL", assume_scheme="https")
4747
processor = process_url
4848

4949

@@ -54,8 +54,8 @@ class XMLMetadataForm(forms.Form):
5454

5555
class SAMLForm(forms.Form):
5656
entity_id = forms.CharField(label="Entity ID")
57-
sso_url = forms.URLField(label="Single Sign On URL")
58-
slo_url = forms.URLField(label="Single Log Out URL", required=False)
57+
sso_url = forms.URLField(label="Single Sign On URL", assume_scheme="https")
58+
slo_url = forms.URLField(label="Single Log Out URL", required=False, assume_scheme="https")
5959
x509cert = forms.CharField(label="x509 public certificate", widget=forms.Textarea)
6060
processor = lambda d: d.cleaned_data
6161

src/sentry/auth/providers/saml2/onelogin/provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# Onelogin specifically calls their Metadata URL a 'Issuer URL'
99
class OneLoginURLMetadataForm(URLMetadataForm):
10-
metadata_url = forms.URLField(label="Issuer URL")
10+
metadata_url = forms.URLField(label="Issuer URL", assume_scheme="https")
1111

1212

1313
SelectIdP = make_simple_setup(OneLoginURLMetadataForm, "sentry_auth_onelogin/select-idp.html")

src/sentry/new_migrations/monkey/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from sentry.new_migrations.monkey.executor import SentryMigrationExecutor
55
from sentry.new_migrations.monkey.fields import deconstruct
66

7-
LAST_VERIFIED_DJANGO_VERSION = (4, 2)
7+
LAST_VERIFIED_DJANGO_VERSION = (5, 0)
88
CHECK_MESSAGE = """Looks like you're trying to upgrade Django! Since we monkeypatch
99
Django in several places, please verify that we have the latest code, and that the
1010
monkeypatching still works as expected. Currently the main things to check are:

src/sentry/signals.py

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from collections.abc import Callable
77
from typing import Any
88

9-
from django.dispatch.dispatcher import NO_RECEIVERS, Signal
9+
from django.dispatch.dispatcher import Signal
1010

1111
from sentry.utils.env import in_test_environment
1212

@@ -79,32 +79,12 @@ def wrapped(func):
7979
wrapped.__doc__ = receiver.__doc__
8080
return wrapped(receiver)
8181

82-
def send_robust(self, sender, **named) -> list[tuple[Receiver, Exception | Any]]:
83-
"""
84-
A reimplementation of send_robust which logs failures, thus recovering stacktraces.
85-
"""
86-
responses: list[tuple[Receiver, Exception | Any]] = []
87-
if not self.receivers or self.sender_receivers_cache.get(sender) is NO_RECEIVERS:
88-
return responses
89-
90-
# Call each receiver with whatever arguments it can accept.
91-
# Return a list of tuple pairs [(receiver, response), ... ].
92-
for receiver in self._live_receivers(sender):
93-
try:
94-
response = receiver(signal=self, sender=sender, **named)
95-
except Exception as err:
96-
if in_test_environment():
97-
if (
98-
_receivers_that_raise is _AllReceivers.ALL
99-
or receiver in _receivers_that_raise
100-
):
101-
raise
102-
103-
logging.exception("signal.failure", extra={"receiver": repr(receiver)})
104-
responses.append((receiver, err))
105-
else:
106-
responses.append((receiver, response))
107-
return responses
82+
def _log_robust_failure(self, receiver: object, err: Exception) -> None:
83+
if in_test_environment():
84+
if _receivers_that_raise is _AllReceivers.ALL or receiver in _receivers_that_raise:
85+
raise
86+
87+
logging.error("signal.failure", extra={"receiver": repr(receiver)}, exc_info=err)
10888

10989

11090
buffer_incr_complete = BetterSignal() # ["model", "columns", "extra", "result"]

src/sentry_plugins/opsgenie/plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class OpsGenieOptionsForm(notify.NotificationConfigurationForm):
3838
attrs={"class": "span6", "placeholder": "e.g. https://api.opsgenie.com/v2/alerts"}
3939
),
4040
help_text="It must be visible to the Sentry server",
41+
assume_scheme="https",
4142
required=True,
4243
)
4344

src/sentry_plugins/redmine/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
class RedmineOptionsForm(forms.Form):
14-
host = forms.URLField(help_text=_("e.g. http://bugs.redmine.org"))
14+
host = forms.URLField(help_text=_("e.g. http://bugs.redmine.org"), assume_scheme="https")
1515
key = forms.CharField(
1616
widget=forms.TextInput(attrs={"class": "span9"}),
1717
help_text="Your API key is available on your account page after enabling the Rest API (Administration -> Settings -> Authentication)",

tests/sentry/plugins/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class DummyForm(forms.Form):
1111
textarea = forms.CharField(widget=forms.Textarea, required=False)
1212
password = forms.CharField(label="A Password", widget=forms.PasswordInput)
1313
choice = forms.ChoiceField(choices=((1, "one"), (2, "two")))
14-
url = forms.URLField()
14+
url = forms.URLField(assume_scheme="https")
1515

1616

1717
class DummyPlugin(Plugin2):

0 commit comments

Comments
 (0)