Skip to content

Session Replay: malformed or truncated .ongoing_segment line crashes ReplayCache.fromDisk with IndexOutOfBoundsException #6806

Not planned

Description

@sahuadarsh0

Integration

sentry-android (sentry-android-replay)

Version

8.66.0 (main @ a8ff282)

Steps to Reproduce

  1. Have an .ongoing_segment file inside replay_<replayId> that contains a line without = (for example, a truncated line such as config.heig left behind if the process is killed mid-writeText(), a blank line, or a screenAtStart value containing a newline since screenAtStart is not filtered for \n/\r the way recording metadata keys are in BaseCaptureStrategy.persistMetadataValue).
  2. Call ReplayCache.fromDisk(options, replayId) (as ReplayIntegration.finalizePreviousReplay() does on next app launch) or ReplayCache.persistSegmentValues(...) on a fresh ReplayCache instance backed by that file.

Expected Result

Malformed lines in .ongoing_segment should be skipped safely or treated as corrupt segment metadata so ReplayCache.fromDisk() deletes the broken replay_<replayId> directory, returns null, and lets finalizePreviousReplay() proceed to cleanupReplays().

Actual Result

Both ReplayCache.persistSegmentValues and ReplayCache.fromDisk unconditionally destructure it.split("=", limit = 2):

lines.associateTo(lastSegment) {
  val (k, v) = it.split("=", limit = 2)
  k to v
}

Any line without = throws java.lang.IndexOutOfBoundsException: Index: 1, Size: 1. In ReplayIntegration.finalizePreviousReplay(), that exception aborts the task before cleanupReplays() runs and leaves the corrupt replay_<replayId> folder on disk.

Activity

  1. linear-code commented on Nov 29, 2026

    @linear-code
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Nov 29, 2026
  3. romtsn commented on Dec 1, 2026

    @romtsn
    Contributor

    hi @sahuadarsh0 thanks for the report! Have you experienced this issue in production? At worst, you'd lose the last segment of a previous replay, but there should be no production crash or anything. I'd also imagine this can rarely happen, so I'd qualify this issue as low-prio or even close it, unless you have the data to back it up that it happens a lot. Thanks!

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Dec 1, 2026
  5. sahuadarsh0 commented on Dec 1, 2026

    @sahuadarsh0
    Author

    Spotted this during code review while working on #6804 rather than from a production crash, so no production telemetry behind it. Totally fine to keep it low-prio or close it.

  6. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Dec 1, 2026
  7. romtsn commented on Dec 1, 2026

    @romtsn
    Contributor

    @sahuadarsh0 thanks, closing then due to weak production evidence!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions