Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9f7695d
Fix WSGI invalid request URI handling
IonDragos2003 May 6, 2026
f8cc835
Simplifying the test request_uri
IonDragos2003 May 6, 2026
a1ca22a
Adding suggestion
IonDragos2003 May 8, 2026
86bf960
Merge branch 'main' into fix-wsgi-invalid-request-uri
IonDragos2003 May 8, 2026
00fb82b
Merge branch 'main' into fix-wsgi-invalid-request-uri
IonDragos2003 May 8, 2026
b980788
Merge branch 'main' into fix-wsgi-invalid-request-uri
emdneto May 8, 2026
7bc9f17
Merge branch 'main' into fix-wsgi-invalid-request-uri
IonDragos2003 May 11, 2026
9f969ea
Fixing falcon tests
IonDragos2003 May 11, 2026
2a204d8
Adding explicit query_string for full_request_uri
IonDragos2003 May 11, 2026
96443ca
Merge branch 'main' into fix-wsgi-invalid-request-uri
emdneto May 11, 2026
db1d8aa
Adding changelog entry
IonDragos2003 May 11, 2026
4d3dc30
Merge branch 'fix-wsgi-invalid-request-uri' of https://github.com/Ion…
IonDragos2003 May 11, 2026
f57ffea
Merge branch 'main' into fix-wsgi-invalid-request-uri
IonDragos2003 May 11, 2026
83f1d68
Merge branch 'main' into fix-wsgi-invalid-request-uri
IonDragos2003 May 12, 2026
e6a470d
Updating test with hardcoded value
IonDragos2003 May 12, 2026
946b23f
Merge branch 'main' into fix-wsgi-invalid-request-uri
IonDragos2003 May 12, 2026
b7cf633
Merge branch 'main' into fix-wsgi-invalid-request-uri
emdneto May 12, 2026
6f6c160
Add changelog fragment
IonDragos2003 May 13, 2026
1834a56
Merge branch 'main' into fix-wsgi-invalid-request-uri
IonDragos2003 May 13, 2026
8738378
Update test
IonDragos2003 May 16, 2026
477e831
Apply suggestions from code review
xrmx May 18, 2026
1ef3895
Merge branch 'main' into fix-wsgi-invalid-request-uri
xrmx May 18, 2026
57e2ab5
Merge branch 'main' into fix-wsgi-invalid-request-uri
emdneto May 18, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ def response_hook(span: Span, environ: WSGIEnvironment, status: str, response_he
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST,
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE,
SanitizeValue,
_parse_url_query,
detect_synthetic_user_agent,
get_custom_headers,
normalise_request_header_name,
Expand Down Expand Up @@ -360,7 +359,8 @@ def collect_request_attributes(
if target is None: # Note: `"" or None is None`
target = environ.get("REQUEST_URI")
if target:
path, query = _parse_url_query(target)
path = environ.get("PATH_INFO")
query = environ.get("QUERY_STRING")
_set_http_target(result, target, path, query, sem_conv_opt_in_mode)
else:
# old semconv v1.20.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,7 @@ def test_request_attributes_with_full_request_uri(self):
HTTP_TARGET: "http://docs.python.org:80/3/library/urllib.parse.html?highlight=params#url-parsing",
}
expected_new = {
URL_PATH: "/3/library/urllib.parse.html",
URL_QUERY: "highlight=params",
Comment thread
IonDragos2003 marked this conversation as resolved.
URL_PATH: self.environ["PATH_INFO"],
Comment thread
IonDragos2003 marked this conversation as resolved.
Outdated
}
self.assertGreaterEqual(
otel_wsgi.collect_request_attributes(self.environ).items(),
Expand All @@ -825,6 +824,32 @@ def test_request_attributes_with_full_request_uri(self):
expected_new.items(),
)

def test_request_attributes_with_invalid_request_uri_uses_wsgi_environ(self):
# Previously raised ValueError when REQUEST_URI was parsed.
self.environ["REQUEST_URI"] = "http://example.com[invalid"
self.environ["PATH_INFO"] = "/safe/path"
self.environ["QUERY_STRING"] = "a=b"

expected_old = {
HTTP_TARGET: self.environ["REQUEST_URI"],
}
expected_new = {
URL_PATH: "/safe/path",
URL_QUERY: "a=b",
}

self.assertGreaterEqual(
otel_wsgi.collect_request_attributes(self.environ).items(),
expected_old.items(),
)
self.assertGreaterEqual(
otel_wsgi.collect_request_attributes(
self.environ,
_StabilityMode.HTTP,
).items(),
expected_new.items(),
)

def test_http_user_agent_attribute(self):
self.environ["HTTP_USER_AGENT"] = "test-useragent"
expected = {HTTP_USER_AGENT: "test-useragent"}
Expand Down
Loading