Skip to content

Commit c47ec4c

Browse files
Fix runId validation in turso/redis facade to allow client-provided runId (#28)
Upstream now sends client-provided runId for run_created events. Both storage.ts AND index.ts facade layers must allow non-null runId for run_created events. Use conditional branching with type assertions to satisfy TypeScript overload resolution for events.create(): - null runId → RunCreatedEventRequest overload - string runId → CreateEventRequest overload https://claude.ai/code/session_016KjC15tQfm7ccAuTBNVyWD Co-authored-by: Claude <noreply@anthropic.com>
1 parent ddc50a6 commit c47ec4c

2 files changed

Lines changed: 4 additions & 12 deletions

File tree

packages/redis/src/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,10 @@ export function createWorld(config: RedisWorldConfig = {}): World {
228228
if (data.eventType !== 'run_created') {
229229
throw new Error('runId must be a string for non run_created events');
230230
}
231-
return storage.events.create(null, data, params);
231+
return storage.events.create(null, data as RunCreatedEventRequest, params);
232232
}
233233

234-
if (data.eventType === 'run_created') {
235-
throw new Error('runId must be null for run_created events');
236-
}
237-
238-
return storage.events.create(runId, data, params);
234+
return storage.events.create(runId, data as CreateEventRequest, params);
239235
}
240236

241237
async function listEvents(

packages/turso/src/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,10 @@ export function createWorld(config: TursoWorldConfig = {}): World {
263263
if (data.eventType !== 'run_created') {
264264
throw new Error('runId must be a string for non run_created events');
265265
}
266-
return storage.events.create(null, data, params);
266+
return storage.events.create(null, data as RunCreatedEventRequest, params);
267267
}
268268

269-
if (data.eventType === 'run_created') {
270-
throw new Error('runId must be null for run_created events');
271-
}
272-
273-
return storage.events.create(runId, data, params);
269+
return storage.events.create(runId, data as CreateEventRequest, params);
274270
}
275271

276272
async function listEvents(

0 commit comments

Comments
 (0)