diff --git a/packages/core/src/v3/serverOnly/idempotencyKeys.ts b/packages/core/src/v3/serverOnly/idempotencyKeys.ts index 59e97dc567..91dac04fd4 100644 --- a/packages/core/src/v3/serverOnly/idempotencyKeys.ts +++ b/packages/core/src/v3/serverOnly/idempotencyKeys.ts @@ -8,14 +8,14 @@ import { IdempotencyKeyOptionsSchema } from "../schemas/api.js"; * @returns The user-provided key, the hash as fallback, or null if neither exists */ export function getUserProvidedIdempotencyKey(run: { - idempotencyKey: string | null; + idempotencyKey: string | null | undefined; idempotencyKeyOptions: unknown; -}): string | null { +}): string | undefined { const parsed = IdempotencyKeyOptionsSchema.safeParse(run.idempotencyKeyOptions); if (parsed.success) { return parsed.data.key; } - return run.idempotencyKey; + return run.idempotencyKey ?? undefined; } /**