Skip to content

Commit 1a5d29a

Browse files
authored
fix: generateId returns string | false as of better-auth@1.3.5 (#13)
1 parent 6b3f746 commit 1a5d29a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/r2.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export const createFileValidator = (config: R2Config) => {
284284
*/
285285
export const createR2Storage = (
286286
config: R2Config,
287-
generateId: (options: { model: string; size?: number }) => string
287+
generateId: (options: { model: string; size?: number }) => string | false
288288
) => {
289289
const { bucket } = config;
290290

@@ -327,6 +327,9 @@ export const createR2Storage = (
327327
}
328328

329329
const fileId = generateId({ model: modelName || "userFile" });
330+
if (!fileId) {
331+
throw new Error("Failed to generate unique file ID. Please try again.");
332+
}
330333
const filename = `${fileId}-${sanitizeFilename(originalName)}`;
331334
r2Key = `user-files/${userId}/${filename}`;
332335

0 commit comments

Comments
 (0)