Skip to content

Commit d44a02f

Browse files
committed
Revert "feat: Add support for DSN paths"
This reverts commit 4acfcb2.
1 parent 32e7a05 commit d44a02f

File tree

2 files changed

+6
-52
lines changed

2 files changed

+6
-52
lines changed

sentry_sdk/utils.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,15 @@ def __init__(self, value):
8484
self.port = self.scheme == "https" and 443 or 80
8585
self.public_key = parts.username
8686
if not self.public_key:
87-
raise BadDsn("Missing public key")
87+
raise BadDsn("Missig public key")
8888
self.secret_key = parts.password
89-
90-
path = parts.path.rsplit("/", 1)
91-
89+
if not parts.path:
90+
raise BadDsn("Missing project ID in DSN")
9291
try:
93-
self.project_id = text_type(int(path.pop()))
92+
self.project_id = text_type(int(parts.path[1:]))
9493
except (ValueError, TypeError):
9594
raise BadDsn("Invalid project in DSN (%r)" % (parts.path or "")[1:])
9695

97-
self.path = "/".join(path) + "/"
98-
9996
@property
10097
def netloc(self):
10198
"""The netloc part of a DSN."""
@@ -109,20 +106,18 @@ def to_auth(self, client=None):
109106
return Auth(
110107
scheme=self.scheme,
111108
host=self.netloc,
112-
path=self.path,
113109
project_id=self.project_id,
114110
public_key=self.public_key,
115111
secret_key=self.secret_key,
116112
client=client,
117113
)
118114

119115
def __str__(self):
120-
return "%s://%s%s@%s%s%s" % (
116+
return "%s://%s%s@%s/%s" % (
121117
self.scheme,
122118
self.public_key,
123119
self.secret_key and "@" + self.secret_key or "",
124120
self.netloc,
125-
self.path,
126121
self.project_id,
127122
)
128123

@@ -134,7 +129,6 @@ def __init__(
134129
self,
135130
scheme,
136131
host,
137-
path,
138132
project_id,
139133
public_key,
140134
secret_key=None,
@@ -143,7 +137,6 @@ def __init__(
143137
):
144138
self.scheme = scheme
145139
self.host = host
146-
self.path = path
147140
self.project_id = project_id
148141
self.public_key = public_key
149142
self.secret_key = secret_key
@@ -153,12 +146,7 @@ def __init__(
153146
@property
154147
def store_api_url(self):
155148
"""Returns the API url for storing events."""
156-
return "%s://%s%sapi/%s/store/" % (
157-
self.scheme,
158-
self.host,
159-
self.path,
160-
self.project_id,
161-
)
149+
return "%s://%s/api/%s/store/" % (self.scheme, self.host, self.project_id)
162150

163151
def to_header(self, timestamp=None):
164152
"""Returns the auth header a string."""

tests/utils/test_general.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import hypothesis.strategies as st
99

1010
from sentry_sdk.utils import (
11-
BadDsn,
12-
Dsn,
1311
safe_repr,
1412
exceptions_from_error_tuple,
1513
format_and_strip,
@@ -113,35 +111,3 @@ def test_filename():
113111
import sentry_sdk.utils
114112

115113
assert x("sentry_sdk.utils", sentry_sdk.utils.__file__) == "sentry_sdk/utils.py"
116-
117-
118-
@pytest.mark.parametrize(
119-
"given,expected",
120-
[
121-
("https://[email protected]/123", "https://sentry.io/api/123/store/"),
122-
("https://[email protected]/bam/123", "https://sentry.io/bam/api/123/store/"),
123-
(
124-
"https://[email protected]/bam/baz/123",
125-
"https://sentry.io/bam/baz/api/123/store/",
126-
),
127-
],
128-
)
129-
def test_parse_dsn_paths(given, expected):
130-
dsn = Dsn(given)
131-
auth = dsn.to_auth()
132-
assert auth.store_api_url == expected
133-
134-
135-
@pytest.mark.parametrize(
136-
"dsn",
137-
[
138-
139-
"https://[email protected]/"
140-
"https://[email protected]/asdf"
141-
"https://[email protected]/asdf/"
142-
"https://[email protected]/asdf/123/"
143-
],
144-
)
145-
def test_parse_invalid_dsn(dsn):
146-
with pytest.raises(BadDsn):
147-
dsn = Dsn(dsn)

0 commit comments

Comments
 (0)