Reject empty agent session ids in websocket event envelopes

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 14:04:02 +00:00
1 parent dd02660502
commit e0a9865d02
1 file changed
+26
+26
View File
@@ -383,6 +383,32 @@ describe("wsServerMessageSchema", () => {
).toThrow();
});
it("rejects agent events with empty session ids", () => {
expect(() =>
wsServerMessageSchema.parse({
type: "event",
channel: WS_EVENT_CHANNELS.agentOutput,
payload: {
sessionId: "",
stream: "stdout",
data: "hello",
},
}),
).toThrow();
expect(() =>
wsServerMessageSchema.parse({
type: "event",
channel: WS_EVENT_CHANNELS.agentExit,
payload: {
sessionId: "",
code: 0,
signal: null,
},
}),
).toThrow();
});
it("rejects unexpected event properties", () => {
expect(() =>
wsServerMessageSchema.parse({