Skip to content

Commit

Permalink
fix: Default path in asgi_scope to empty string (#21602)
Browse files Browse the repository at this point in the history
Sometimes requests come in with an empty asgi scope
Default path to "" in these cases just so string startswith doesn't break
  • Loading branch information
frankh authored Apr 17, 2024
1 parent ca49427 commit 86cd54c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion posthog/settings/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def traces_sampler(sampling_context: dict) -> float:
path = sampling_context.get("wsgi_environ", {}).get("PATH_INFO")
force_sample = bool(sampling_context.get("wsgi_environ", {}).get("HTTP_FORCE_SAMPLE"))
if os.environ.get("SERVER_GATEWAY_INTERFACE") == "ASGI":
path = sampling_context.get("asgi_scope", {}).get("path")
path = sampling_context.get("asgi_scope", {}).get("path", "")
headers = sampling_context.get("asgi_scope", {}).get("headers", [])
for name, value in headers:
if name.lower().replace(b"_", b"-") == "force-sample":
Expand Down

0 comments on commit 86cd54c

Please sign in to comment.