◐ Shell
clean mode source ↗

feat(pyramid): Set user.id on spans when PII is enabled by ericapisani · Pull Request #6606 · getsentry/sentry-python

Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: sentry_sdk/integrations/pyramid.py#L92

Potential issue: In the Pyramid integration, `scope.set_user` is called with only the
user ID (`{"id": user_id}`). This action replaces the entire `_user` dictionary on the
isolation scope. If any other middleware or integration has previously set user
properties like email or username, that information will be lost. Consequently,
subsequent telemetry spans will only contain the `user.id` attribute, losing other
valuable user context. This behavior is inconsistent with other integrations, such as
Quart, which correctly merge new user data with existing properties.