Skip to content
All findings

sentry-sdk 3.0 Flask upgrade: Unknown option 'send_default_pii', start_span() unexpected keyword 'op', then silent PII, logging and span-loop changes

Published 30 Nov 2026

Upgrading a Flask app from sentry-sdk 2.76 to 3.0.2 hit four TypeErrors (transaction_style, send_default_pii, before_send_transaction, start_span(op=)). After those were fixed, the app ran but sent passwords, local variables and client IPs, stopped turning logger.error into events, and couldn't drop /health with ignore_spans. With a DSN that has a port, the SDK traced its own uploads and sent an envelope every 5 seconds. Fixes are below.

Moving a Flask app from sentry-sdk 2.76.0 to 3.0.2 hits four TypeErrors for removed options: three at import, one only when a request runs. Once those are fixed it runs, but it changes behaviour without any error. Without send_default_pii it sends passwords, local variables and IPs. logger.error() no longer creates events. ignore_spans can't drop /health. With a DSN that has a port, the SDK traces its own uploads in a loop that never stops. The fixed init() is at the end.

log
TypeError: FlaskIntegration.__init__() got an unexpected keyword argument 'transaction_style'TypeError: Unknown option 'send_default_pii'TypeError: Unknown option 'before_send_transaction'TypeError: start_span() got an unexpected keyword argument 'op'

Environment

sentry-sdk 2.76.0 → 3.0.2, Flask 3.1.3, Python 3.12 (python:3.12-slim). The app has FlaskIntegration, before_send, before_send_transaction, traces_sample_rate=1.0, a manual span, breadcrumbs and logging. A local mock DSN logs every envelope. Reproduced 2026-11-30.

1. `FlaskIntegration(transaction_style=...)` raises TypeError in sentry-sdk 3.0

transaction_style is gone from all server integrations. Segments are now always named after the route pattern (/orders/<int:oid>). Fix: FlaskIntegration(). Any alerts or dashboards that matched endpoint-style names need updating.

2. `Unknown option 'send_default_pii'` in sentry-sdk 3.0: just deleting it leaks data

The obvious fix is to delete the line, and that's what leaks. 3.0 replaces it with data_collection, and the new defaults collect more. The same requests as received by the mock DSN (condensed from before.log and after-step4.log):

log
2.76.0  user=None  X-Forwarded-For='[Filtered]'  req.data={'password': '[Filtered]', ...}  vars={'password': '[Filtered]', 'api_key': '[Filtered]'}3.0.2   user={'ip_address': '203.0.113.9'}  X-Forwarded-For='203.0.113.9'  req.data={'password': 'hunter2', 'user': 'ada'}        vars={'oid': '13', 'password': "'hunter2'", 'api_key': "'sk_live_SECRET123'"}

Request bodies are now sent unfiltered, and local variables in stack frames are no longer scrubbed. Fix: set data_collection explicitly (the full block is under Final working setup). "stack_frame_variables": {"mode": "denylist"} is the setting that brings back [Filtered] for password and api_key.

3. `Unknown option 'before_send_transaction'` in sentry-sdk 3.0: ignore_spans won't drop Flask routes

Transactions are gone, and all tracing is span streaming now. The migration guide points to ignore_spans for dropping spans. However, ignore_spans=["/health"] still sent the /health segment. In a traces_sampler, the Flask segment's name is still generic WSGI request. It is renamed to the route only later, so a route-name rule never matches. The fix that worked was to sample on the raw path:

python
traces_sampler=lambda ctx: 0.0 if ctx.get("wsgi_environ", {}).get("PATH_INFO") == "/health" else 1.0,

4. `start_span() got an unexpected keyword argument 'op'` in sentry-sdk 3.0: a 500 at request time

Import succeeds. The error is raised only when the span is created, so GET /orders/1 went from 200 to 500. start_span now takes name, attributes, parent_span, active and links. Fix:

python
with sentry_sdk.start_span(name="SELECT order", attributes={"sentry.op": "db"}):

Before deploying, grep for start_span(op=, description= and start_transaction. None of them fail at import.

5. `logger.error()` no longer creates Sentry events in sentry-sdk 3.0

On 2.76, log.error("payment provider timeout ...") created an error event. On 3.0.2 nothing arrived: no event, and no loading order 7 breadcrumb. LoggingIntegration is no longer auto-enabled, and its event_level now defaults to None. Fix: LoggingIntegration(event_level=logging.ERROR). Once enabled, it also ships INFO logs as Sentry Logs (log envelope items) by default. Pass level=None if you don't want that.

6. sentry-sdk 3.0 sends an envelope every 5 seconds when the DSN has a port

With dsn="http://key@host:9000/1" (for example, a self-hosted Sentry on its usual port), a single request starts a loop. Each upload is recorded as an http.client span (POST http://127.0.0.1:9000/api/1/envelope/) in that request's trace. That span is uploaded on the next flush, which creates another span, and so on:

log
t=10s items received=2 of which self-upload spans=1t=20s items received=4 of which self-upload spans=3t=30s items received=6 of which self-upload spans=5

Two control runs show nothing extra: 2.76.0 with the same DSN, and 3.0.2 with a DSN that has no port. Cause: is_sentry_url checks whether the DSN netloc (127.0.0.1:9000) appears in the connection host (127.0.0.1), which fails when there's a port. That's the known open issue #7332. In 2.x the extra span was harmless. Span streaming in 3.0 turns it into a loop. Fix: ignore_spans patterns use fullmatch, so the pattern must cover the whole name:

python
ignore_spans=[re.compile(r".*/api/\d+/envelope/.*")],

Final working setup (sentry-sdk 3.0.2, Flask)

python
sentry_sdk.init(    dsn=DSN,    integrations=[FlaskIntegration(), LoggingIntegration(event_level=logging.ERROR)],    data_collection={        "user_info": False,        "http_bodies": [],        "http_headers": {"request": {"mode": "denylist", "terms": ["forwarded", "-ip", "remote-", "via", "-user"]}},        "cookies": {"mode": "denylist", "terms": ["forwarded", "-ip", "remote-", "via", "-user"]},        "url_query_params": {"mode": "denylist", "terms": ["forwarded", "-ip", "remote-", "via", "-user"]},        "stack_frame_variables": {"mode": "denylist"},    },    ignore_spans=[re.compile(r".*/api/\d+/envelope/.*")],    traces_sampler=lambda ctx: 0.0 if ctx.get("wsgi_environ", {}).get("PATH_INFO") == "/health" else 1.0,    before_send=before_send,)

Same five requests: the same events as on 2.76 (locals and IP filtered, the logger event back, no /health trace), except that request bodies are now left out entirely. The loop stayed at 0 self-upload spans over 30 s.

What didn't work

  • Deleting send_default_pii=False: it leaks data (section 2).
  • ignore_spans=["/health"] or {"name": "/health"}: the segment was still sent.
  • ignore_spans=[re.compile(r"/api/\d+/envelope/")]: no match, because of fullmatch.

Sources