Skip to content

Remove sanitation on room load - #2738

Open
tlokeshrao wants to merge 9 commits into
devfrom
load-rooms-invalid-parent
Open

Remove sanitation on room load#2738
tlokeshrao wants to merge 9 commits into
devfrom
load-rooms-invalid-parent

Conversation

@tlokeshrao

@tlokeshrao tlokeshrao commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Description

Loosen RoomMessageStore validation so a room with an invalid parentMessageId in its message tree no longer blocks load, ask, or persist. Broken parent references now log a warn and continue instead of throwing.

Changes Made

  • Wrap validateForPersistence calls at four sites with try/catch + classLogger.warn:
    • loadFromPersistedJson — open corrupt rooms from the durable store
    • normalizeForProviderPayload — allow ask to proceed against a corrupt tree
    • validateSerializedProjection (called by persist) — don't block DB write on a broken tree
    • validateProviderPayload — the walker-produced branch can still contain an orphan-parent message
  • Tool-call/tool-result matching inside validateProviderPayload remains strict — genuine payload defects still fail loudly.

How to Test

  1. Open a room whose persisted messages contain a message with a parentMessageId not present in the tree (e.g. STREAMING_PLACEHOLDER_ID).
  2. Ask a new message. Room loads, ask completes, response persists.
  3. Warn logs (Failed to validate messages for …) appear at load and again during ask/persist for that room.

Notes

  • No self-heal: the orphan-parent message stays in room.messages and will produce a warn every subsequent load/ask/persist. Pruning orphan-parent messages inside normalizeForProviderPayload would provide real self-heal; follow-up if log noise becomes a problem.

@snyk-io

snyk-io Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@tlokeshrao
tlokeshrao marked this pull request as ready for review July 15, 2026 18:57
@tlokeshrao
tlokeshrao requested a review from a team as a code owner July 15, 2026 18:57
@tlokeshrao tlokeshrao changed the title Allow chats with invalid parent message id Remove sanitation on room load Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant