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

fix(scope): `set_user` should not overwrite existing user data

Open sentrivana opened this issue 1 year ago • 0 comments

According to https://develop.sentry.dev/sdk/unified-api/#scope set_user should "shallow merge" user data. We're instead overwriting it.

Changes in this PR:

  • set_user called with a non-empty dict will now update, rather than replace, current user data on the scope
  • To reset the current user, set_user needs to be called with None or {} as argument.

These are both breaking changes. Added them to the MIGRATION_GUIDE.

Session behavior is left unchanged.

Fixes https://github.com/getsentry/sentry-python/issues/933


General Notes

Thank you for contributing to sentry-python!

Please add tests to validate your changes, and lint your code using tox -e linters.

Running the test suite on your PR might require maintainer approval. Some tests (AWS Lambda) additionally require a maintainer to add a special label to run and will fail if the label is not present.

For maintainers

Sensitive test suites require maintainer review to ensure that tests do not compromise our secrets. This review must be repeated after any code revisions.

Before running sensitive test suites, please carefully check the PR. Then, apply the Trigger: tests using secrets label. The label will be removed after any code changes to enforce our policy requiring maintainers to review all code revisions before running sensitive tests.

sentrivana avatar Feb 15 '24 16:02 sentrivana