Skip to content

Internal error if attachment files are missing #3334

Closed
@k-j0

Description

@k-j0

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.11.0

Steps to Reproduce

Attach a file that doesn't exist:

with sentry_sdk.configure_scope() as scope:
    scope.add_attachment(path='this_file_does_not_exist', filename='foo')

Then try to capture an event:

division_by_zero = 1 / 0

Expected Result

The event gets submitted successfully, without the missing file (potentially with some information that the file was not found, to help with debugging? but anything showing up in the dashboard is better than nothing at all).

Actual Result

The following errors get triggered, and no events show up in the Sentry dashboard:

[sentry] ERROR: Internal error in sentry_sdk
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/sentry_sdk/envelope.py", line 188, in get_bytes
    with open(self.path, "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'this_file_does_not_exist'
[sentry] ERROR: Internal error in sentry_sdk
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/sentry_sdk/transport.py", line 582, in send_envelope_wrapper
    self._send_envelope(envelope)
  File "/usr/local/lib/python3.10/dist-packages/sentry_sdk/transport.py", line 455, in _send_envelope
    envelope.serialize_into(f)
  File "/usr/local/lib/python3.10/dist-packages/sentry_sdk/envelope.py", line 137, in serialize_into
    item.serialize_into(f)
  File "/usr/local/lib/python3.10/dist-packages/sentry_sdk/envelope.py", line 310, in serialize_into
    headers["length"] = len(bytes)
TypeError: object of type 'NoneType' has no len()

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions