Skip to content

Commit 8dea32a

Browse files
committed
fix(runtime-host): reject sparse imported session ids
Generated-by: Codex
1 parent a573527 commit 8dea32a

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎packages/runtime-host/src/__tests__/external-session-protocol.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,30 @@ describe('external Session protocol', () => {
173173
);
174174
});
175175

176+
test('rejects sparse imported Session id arrays', () => {
177+
const importedSessionIds = Array<string>(1);
178+
179+
assert.throws(
180+
() =>
181+
decodeExternalSessionCatalogQueryResult({
182+
sessions: [
183+
{
184+
id: 'source-1',
185+
name: 'Imported source',
186+
hostCwd: '/workspace',
187+
importState: {
188+
importedCount: 1,
189+
importedSessionIds,
190+
isImporting: false,
191+
},
192+
},
193+
],
194+
nextCursor: null,
195+
}),
196+
isProtocolError,
197+
);
198+
});
199+
176200
test('rejects open-ended, malformed, and oversized frames', () => {
177201
assert.throws(
178202
() =>

‎packages/runtime-host/src/protocol/external-session.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ function decodeExternalSessionImportState(
260260
) {
261261
throw invalidProtocolFrame('Invalid external Session imported Session ids');
262262
}
263-
const importedSessionIds = state.importedSessionIds.map((id) =>
263+
const importedSessionIds = Array.from(state.importedSessionIds, (id) =>
264264
requireEntityId(id, 'imported Session id'),
265265
);
266266
const importedCount = requireCount(state.importedCount, 'external Session imported count');

0 commit comments

Comments
 (0)