Skip to content

last_event_id() crash: AttributeError: 'Scope' object has no attribute '_last_event_id'. #3113

Closed
@adamchainz

Description

@adamchainz

How do you use Sentry?

Sentry Saas (sentry.io)

Version

master

Steps to Reproduce

Run this file:

import sentry_sdk

sentry_sdk.init()

with sentry_sdk.push_scope() as scope:
    sentry_sdk.last_event_id()

Expected Result

No crash.

Actual Result

Crash:

$ python example.py
Traceback (most recent call last):
  File "/.../example.py", line 6, in <module>
    sentry_sdk.last_event_id()
  File "/.../sentry_sdk/api.py", line 343, in last_event_id
    return Scope.last_event_id()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/.../sentry_sdk/scope.py", line 330, in last_event_id
    return cls.get_isolation_scope()._last_event_id
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Scope' object has no attribute '_last_event_id'. Did you mean: 'last_event_id'?

#3064 added last_event_id() and _last_event_id but I think it missed copying _last_event_id in Scope.__copy__.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions