Repository navigation
Conversation
Fixes getsentry#8090 Signed-off-by: Mark Colley <39366189+M-Colley@users.noreply.github.com>
PR risk: mediumFor commit Main concerns: data sent to Sentry, host performance, reach. This label is a hint for reviewers, not an approval. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7472999. Configure here.
| {"modules": dict(self)}, | ||
| max_value_length=self._max_value_length, | ||
| custom_repr=self._custom_repr, | ||
| )["modules"] |
There was a problem hiding this comment.
Mutation path drops truncation metadata
Medium Severity
When an event processor mutates event["modules"], __sentry_repr__ re-serializes through a nested serialize() call and returns only the inner modules mapping. Truncation annotations from that call never reach the outer event, so _meta for shortened module values is omitted. The cache path already falls back to a plain copy to preserve those annotations.
Reviewed by Cursor Bugbot for commit 7472999. Configure here.
| super().__init__(data) | ||
| self._max_value_length = max_value_length | ||
| self._custom_repr = custom_repr | ||
| self._mutated = False |
There was a problem hiding this comment.
Dict subclass rejects no-arg construction
Medium Severity
_SerializedModules.__init__ requires data, so same-type construction with no arguments fails. Standard dict operations that do that (copy(), |, copy.copy(), deepcopy) raise TypeError on event["modules"]. If an event processor hits one of those, the callback error drops the event.
Reviewed by Cursor Bugbot for commit 7472999. Configure here.
| {"modules": dict(self)}, | ||
| max_value_length=self._max_value_length, | ||
| custom_repr=self._custom_repr, | ||
| )["modules"] |
There was a problem hiding this comment.
Nested serialize clears capture-event guard
Low Severity
Mutated modules call serialize() from inside the outer serialize(). The inner finally sets disable_capture_event back to False while the outer walk is still running, so later event fields serialize with capture enabled again.
Reviewed by Cursor Bugbot for commit 7472999. Configure here.


Description
ModulesIntegrationpreviously attached the raw_get_installed_modules()dictionary to every error event, causingserialize()to walk every installed distribution entry on each captured error event. This change caches the serialized modules dictionary insentry_sdk/integrations/modules.pykeyed by source mapping identity,max_value_length, andcustom_repr. Specifically, each event receives a_SerializedModuleswrapper whose__sentry_repr__()method returns a fresh plaindictduringserialize(), isolating per-event mutations inbefore_sendand re-serializing under themodulespath if an event processor mutates the mapping. When serialization produces_metaannotations,_get_serialized_modules()falls back to returning a plain copy soserialize()records event metadata normally. Regression tests intests/integrations/modules/test_modules.pyverify single-pass module serialization,before_sendand event processor mutation isolation, andmax_value_lengthtruncation.Issues