feat(transport): Add EnvelopePrinterTransport for debug logging #6181
3 issues
High
Overriding __class__ as a property breaks isinstance and type identity - `sentry_sdk/transport.py:1095-1099`
The __class__ property dynamically returns self._inner.__class__, which causes isinstance(printer, _EnvelopePrinterTransport) to return False and type(printer) to report the inner transport's class. This is a significant side effect that can confuse Sentry's internal type checks (e.g., isinstance(transport, HttpTransport) checks elsewhere in the SDK), break debugging/logging, and cause subtle bugs in any code that relies on type identity of the transport. It also conflicts with backwards compatibility expectations of the Transport interface.
Low
__getattr__ implementation could cause infinite recursion in edge cases - `sentry_sdk/transport.py:1165-1168`
__getattr__ accesses self._inner without guarding against the case where _inner doesn't exist, which could cause infinite recursion if __getattr__ is somehow invoked before self._inner is assigned in __init__. While normal code paths don't trigger this (since __init__ either completes successfully or raises before the object is created), this violates Python best practices for __getattr__ implementation and could be triggered in edge cases like object deserialization, introspection tools, or metaclass manipulation. The standard pattern is to use object.__getattribute__(self, '_inner') or guard with if name == '_inner': raise AttributeError(name).
Bare except swallows all exceptions during envelope printing - `sentry_sdk/transport.py:1124-1125`
The except Exception: pass block silently discards any error during debug printing, including programming errors. While the intent (don't break envelope sending due to debug logging) is reasonable, swallowing without even a debug log makes diagnosing issues with the printer itself impossible. Consider logger.debug("Failed to print envelope", exc_info=True) so failures are visible when debug logging is enabled.
4 skills analyzed
| Skill | Findings | Duration | Cost |
|---|---|---|---|
| code-review | 3 | 42.2s | $2.09 |
| find-bugs | 0 | 1m 9s | $0.78 |
| skill-scanner | 0 | 16.2s | $0.12 |
| security-review | 0 | 15.1s | $0.11 |
Duration: 2m 22s · Tokens: 427.2k in / 5.1k out · Cost: $3.10 (+verification: $2.36, +merge: $0.00, +dedup: $0.01)