Skip to content

[do not merge] testing merge - #8319

Merged
sentrivana merged 6 commits into
major/3.0from
ivana/major/test-test-merge
Nov 17, 2026
Merged

sentrivana merged 6 commits into
major/3.0from
ivana/major/test-test-merge

Conversation

@sentrivana

Copy link
Copy Markdown
Collaborator

Description

Issues

Reminders

sentry-junior Bot and others added 5 commits November 17, 2026 13:12
Django tests take long, split them off into a separate group so that we
can parallelize better.

New layout:

- **Web 1**: Django
- **Web 2**: Flask, Starlette, FastAPI (the rest of the old Web 1)
- **Web 3**: aiohttp, asgi, bottle, falcon, litestar, pyramid, quart,
sanic, starlite, tornado (the old Web 2)


<!-- junior-request-attribution:start -->
via @sentrivana.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0BTREZTS2Z%3A1794920307.639339 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0BTREZTS2Z%3A1794920307.639339)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0BTREZTS2Z%3A1794920307.639339/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Ivana Kellyer <131587164+sentrivana@users.noreply.github.com>
…8302)

The W3C baggage format allows optional whitespace around '=' in a list
member. from_incoming_header only stripped the item as a whole, so
'sentry-sample_rand = 0.5' produced the key 'sample_rand ' and the value
' 0.5'. The incoming sample_rand was then ignored and the corrupted keys
were re-sent downstream percent-encoded.

### Description
<!-- What changed and why? -->

#### Issues
<!--
* resolves: #1234
* resolves: LIN-1234
-->

#### Reminders
- Please add tests to validate your changes, and lint your code using
`uv run ruff`.
- Add GH Issue ID _&_ Linear ID (if applicable)
- PR title should use [conventional
commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type)
style (`feat:`, `fix:`, `ref:`, `meta:`)
- For external contributors:
[CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md),
[Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord
community](https://discord.gg/Ww9hbqr)
TL;DR: Get rid of cases where a name could be possibly undefined,
because there exists a code branch where it's not set.

### Description

Turns on mypy's `possibly-undefined` error code. It flags names that are
only assigned on some code paths (in one `if` branch, inside a `try`, in
a conditional import) and then used where they might not be bound. At
runtime that's an `UnboundLocalError`, which in the SDK would crash the
host app's code path.

It reported 15 errors in 11 files. Nearly all were correct code that
mypy couldn't prove was safe. They're fixed without changing behavior:

- **Initialize before branching**: `name = None` in the
Litestar/Starlite route handler patch (falls through to the existing
`_DEFAULT_TRANSACTION_NAME` fallback), and moved `agent_name = None` out
of the `try` in `langchain._get_request_data`.
- **Restructure so the binding is obvious**:
- `transport.py`: return `PoolManager` straight from the SOCKS `except
ImportError` instead of tracking a `use_socks_proxy` flag.
- `spotlight.py`: compute `spotlight_js_url` before the `try`. `urljoin`
doesn't raise `URLError`, so the exception handling stays the same.
- `chalice.py`: pick the patched class once and use it for both reading
and patching `_get_view_function_response`, instead of checking the
version twice.
- `stdlib.py`: `set_on_span` starts as `None` and the tunnel block
checks it instead of `span`. They're set together, and spans don't
define `__bool__`, so the two checks are equivalent.
- **Targeted ignore**: `grpc/aio/server.py` keeps its four explicit
`request_streaming`/`response_streaming` branches, which are exhaustive,
so the final `handler_factory(wrapped, ...)` call gets `# type:
ignore[possibly-undefined]`.
- **Fix an annotation**: `beam.raise_exception` always re-raises, so it
now returns `NoReturn` instead of `None`.

Latent bugs, fixed minimally (I don't know of a real trigger for
either):

- `mcp.py`: `_tool_handler_wrapper` and `_prompt_handler_wrapper` leave
`handler_name` unbound if they get no positional args and no truthy
`name` kwarg. That raises `UnboundLocalError` before the user's handler
runs. Both now default to `"unknown"`, the same as
`_resource_handler_wrapper` already does.
- `quart.py`: `_request_websocket_started` leaves `request_websocket`
unbound if neither a request nor a websocket context is active. That
shouldn't happen for `request_started`/`websocket_started` signals. It
now returns early in that case. The branches are reordered so the
websocket context still wins when both are active, as before.

`enable_error_code` now lists both `possibly-undefined` and
`unused-awaitable` (from #8281, merged into this
branch). The sibling mypy follow-up PRs will still conflict trivially on
that line; merge the lists when rebasing.

Follow-up from #8281.

<!-- junior-request-attribution:start -->
via @sentrivana.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A7a83c05e74f882736a37443f4dfc9ae1 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A7a83c05e74f882736a37443f4dfc9ae1)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A7a83c05e74f882736a37443f4dfc9ae1/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Ivana Kellyer <131587164+sentrivana@users.noreply.github.com>
The spans may be split across multiple envelopes if the worker takes more than 5 seconds to start up, because the time-based flush condition can collect buckets before the corresponding segment has finished.
Run independent steps in parallel.
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 59186 passed | ⏭️ 3035 skipped | Total: 62221 | Pass Rate: 95.12% | Execution Time: 235m 9s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -84881
Passed Tests 📉 -80059
Failed Tests —
Skipped Tests 📉 -4822

All tests are passing successfully.

✅ Patch coverage is 90.00% (9 of 10 changed executable lines covered; target 80%).
Project statement coverage is 90.11% (down 0.14 percentage points from base (3a9efc8) to head (1df5669)).

Changed files with executable lines (8)
File Patch coverage Changed executable lines
sentry_sdk/integrations/quart.py 66.67% 2/3 covered; missed: 131; partial branches: 128
sentry_sdk/integrations/beam.py 100.00% 1/1 covered
sentry_sdk/integrations/grpc/aio/server.py 100.00% 1/1 covered
sentry_sdk/integrations/langchain.py 100.00% 1/1 covered
sentry_sdk/integrations/litestar.py 100.00% 1/1 covered
sentry_sdk/integrations/starlite.py 100.00% 1/1 covered
sentry_sdk/tracing_utils.py 100.00% 1/1 covered
sentry_sdk/transport.py 100.00% 1/1 covered
Coverage diff
@@            Coverage Diff             @@
##        master     #8319       +/-##
==========================================
- Coverage    90.25%    90.11%    -0.14%
==========================================
  Files          203       200        -3
  Tracked lines     27330     22082     -5248
  Branches     10242      7736     -2506
==========================================
- Hits         24665     19898     -4767
+ Misses        2665      2184      -481
+ Partials      1555      1276      -279

Generated by Coverage Action

@sentrivana
sentrivana force-pushed the ivana/major/test-test-merge branch from c77adae to 1df5669 Compare November 17, 2026 16:03
@sentrivana
sentrivana merged commit 1df5669 into major/3.0 Nov 17, 2026
163 checks passed
@sentrivana
sentrivana deleted the ivana/major/test-test-merge branch November 17, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants