Skip to content

improvement(mothership): do not silently re-route missing stream id#4295

Merged
icecrasher321 merged 1 commit intostagingfrom
improvement/stream-ref-check
Apr 24, 2026
Merged

improvement(mothership): do not silently re-route missing stream id#4295
icecrasher321 merged 1 commit intostagingfrom
improvement/stream-ref-check

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

Summary

Stream ID must exist

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 24, 2026 11:33pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 24, 2026

PR Summary

Low Risk
Low risk: tightens client-side validation to reject events with missing/empty streamId, which may cause previously accepted malformed events to be dropped but doesn’t alter core processing logic.

Overview
Tightens stream event envelope validation by requiring stream.streamId to be a non-empty string in isStreamRef, preventing events with empty/missing stream IDs from being accepted (and potentially silently re-routed).

Reviewed by Cursor Bugbot for commit eb6fa2c. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 24, 2026

Greptile Summary

This PR tightens the isStreamRef type guard in the copilot session contract by adding a non-empty length check (value.streamId.length > 0), preventing an empty-string streamId from passing validation and being silently forwarded downstream.

Confidence Score: 5/5

Safe to merge — single-line guard addition with no risk of regression.

The change is a one-liner that adds a logically correct, non-breaking constraint. It only tightens validation for an edge case (empty streamId) that should never be valid. No other P1/P0 findings present.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/lib/copilot/request/session/contract.ts Adds a non-empty string guard on streamId in isStreamRef; change is minimal, correct, and consistent with the rest of the validator.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Raw stream event JSON] --> B[parsePersistedStreamEventEnvelopeJson]
    B --> C{Valid JSON?}
    C -- No --> D[Return: invalid_json error]
    C -- Yes --> E[parsePersistedStreamEventEnvelope]
    E --> F{isContractEnvelope?}
    F -- Yes --> G[Return: ok=true]
    F -- No --> H{isSyntheticFilePreviewEventEnvelope?}
    H -- Yes --> G
    H -- No --> I[Return: invalid_stream_event error]
    F --> J[isValidEnvelopeShell]
    J --> K[isStreamRef]
    K --> L{streamId is string?}
    L -- No --> M[FAIL]
    L -- Yes --> N{streamId.length > 0?}
    N -- No --> M
    N -- Yes --> O[Continue validation...]
Loading

Reviews (1): Last reviewed commit: "improvement(mothership): do not silently..." | Re-trigger Greptile

@icecrasher321 icecrasher321 merged commit f16d17b into staging Apr 24, 2026
14 checks passed
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