fix(pydantic-ai): Use first-class hooks when available #5947
@sentry/warden / warden: find-bugs
completed
Apr 10, 2026 in 6m 52s
1 issue
find-bugs: Found 1 issue (1 low)
Low
Inconsistent metadata check may overwrite user-provided empty dict - `sentry_sdk/integrations/pydantic_ai/patches/agent_run.py:115-116`
The condition if not metadata: at lines 115 and 164 uses a falsy check, while the analogous check in patched_init at line 106 uses if metadata is None:. If a user explicitly passes metadata={} to Agent.run() or Agent.run_stream(), the empty dict will be replaced with {"_sentry_span": None} rather than having the key added to the user's dict. This inconsistency could break code that holds a reference to the original empty dict expecting it to be mutated.
Duration: 6m 50s · Tokens: 2.0M in / 27.5k out · Cost: $3.22 (+extraction: $0.01, +fix_gate: $0.00)
Loading