sentry-python icon indicating copy to clipboard operation
sentry-python copied to clipboard

fix: set default Scope._transaction_info value to None

Open andrewsapw opened this issue 1 year ago • 3 comments

In #1490, the ._transaction_info property was added to the Scope class. However, there are some issues with this property:

  • It causes the error transaction_info: Discarded unknown attribute in older versions of the UI.
  • There is inconsistency in how the field is handled. Although it is marked as Mapping[str, str], in some places (for example, here), it is checked against None.

This PR sets the default value of Scope._transaction_info to None.

andrewsapw avatar Oct 10 '24 13:10 andrewsapw

@andrewsapw Could you please help me understand the problem you are experiencing?

It causes the error transaction_info: Discarded unknown attribute in older versions of the UI.

Regarding this error, could you please share a screenshot of the error message (or a link to the page, if you are using Sentry's SaaS offering)?

There is inconsistency in how the field is handled. Although it is marked as Mapping[str, str], in some places (for example, here), it is checked against None.

We can likely remove these checks against None, unless we can find somewhere where the field is set to None.

szokeasaurusrex avatar Oct 21 '24 14:10 szokeasaurusrex

@szokeasaurusrex of course! Screenshot of the error: image

andrewsapw avatar Oct 22 '24 11:10 andrewsapw

@andrewsapw Could you please also share a code snippet that reproduces this issue? And what version of Sentry self-hosted are you using?

szokeasaurusrex avatar Oct 22 '24 11:10 szokeasaurusrex

@szokeasaurusrex , example of code that reproduces this issue:

sentry_sdk.capture_message("[INFO] Test .capture_message", level="info")

Version of Sentry: 22.6.0 e68da5c

andrewsapw avatar Oct 24 '24 11:10 andrewsapw

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 79.61%. Comparing base (fe4b88b) to head (92967cd). Report is 85 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3641      +/-   ##
==========================================
- Coverage   79.98%   79.61%   -0.37%     
==========================================
  Files         139      139              
  Lines       15445    15451       +6     
  Branches     2624     2627       +3     
==========================================
- Hits        12353    12301      -52     
- Misses       2219     2280      +61     
+ Partials      873      870       -3     
Files with missing lines Coverage Δ
sentry_sdk/scope.py 86.19% <100.00%> (+0.25%) :arrow_up:

... and 6 files with indirect coverage changes

codecov[bot] avatar Dec 19 '24 20:12 codecov[bot]

Hey @andrewsapw thanks for your work.

I will close this PR, because changing the type of the filed to be nullable is too dangerous (we have a very big user base) and the message you receive is just telling you that in your vesion of sentry this field is not known and therefore discarded.

Sorry.

antonpirker avatar Feb 20 '25 12:02 antonpirker