Repository navigation
fix(replays): Count malformed recording payloads instead of reporting errors - #132186
Draft
sentry-junior[bot] wants to merge 4 commits into
Draft
sentry-junior[bot] wants to merge 4 commits into
sentry-junior[bot] wants to merge 4 commits into
Conversation
… errors A recording whose header line isn't valid JSON (e.g. compressed bytes in the header slot) was logged with logger.exception, creating error events for client data we can't recover. Drop these with a replays.consumer.recording.invalid metric tagged by reason and a warning log instead. The same applies to bodies that are neither zlib nor JSON. Fixes REPLAY-1043 Co-Authored-By: George Gritsouk <george.gritsouk@sentry.io>
gggritso
reviewed
Nov 23, 2026
gggritso
left a comment
Member
There was a problem hiding this comment.
Makes sense, just a small o11y request
Use sentry_sdk.metrics.count instead of a Datadog counter and a warning log, so dropped invalid recordings show up in Sentry metrics.
gggritso
reviewed
Nov 23, 2026
gggritso
left a comment
Member
There was a problem hiding this comment.
Another question about telemetry
Log each dropped invalid recording to Sentry Logs with the org and project slugs, DSN key, payload size and first bytes, and the SDK, environment, release, replay type, browser, and OS from the replay event, so we can trace malformed payloads back to their sender.
gggritso
reviewed
Nov 23, 2026
gggritso
left a comment
Member
There was a problem hiding this comment.
Looking better, a few more questions
Drop the project and organization slug lookup, plus the release and segment id attributes, from the invalid recording log.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The recording consumer drops payloads whose header line can't be parsed, but it logs them with
logger.exception. That makes an error event (via theinternalhandler) for client data we can't recover, and it puts the raw recording bytes into the event's frame vars.The case that prompted this: a payload whose "header" is compressed bytes instead of
{"segment_id":N}.json.loadsdecodes the bytes as UTF-8 first, so it fails withUnicodeDecodeError: 'utf-8' codec can't decode byte 0x9c in position 1(0x9cis the second byte of the zlib header).Changes:
parse_headersanddecompress_segmentraiseInvalidRecording(reason), aDropSilentlysubclass. The reasons aremissing_headers,invalid_headers_json,invalid_segment_id, andinvalid_body.parse_recording_eventcatches it, reports it, and re-raises:replays.consumer.recording.invalid, with areasonattributeparse_headersdrops its now-unusedreplay_idargument.Behavior is otherwise unchanged: these segments were already dropped. Rejecting them at ingest with an outcome belongs in Relay and is out of scope here.
Fixes REPLAY-1043
via George Gritsouk.
--
View Session [Sentry]