From a8b7c05e0c278df1f619cb9ac2538de90ab99982 Mon Sep 17 00:00:00 2001 From: "Ni Z.H." <9588882+nzhdotme@users.noreply.github.com> Date: Fri, 27 Mar 2026 06:39:18 +0800 Subject: [PATCH] Handle null exif.tags in getOffsetFromExif (#389) Handle null exif.tags in getOffsetFromExif `Object.values()` throws "Cannot convert undefined or null to object" when `exif.tags` or `exifr` is null/undefined. This occurs when uploading images that lack EXIF data (e.g., AI-generated images, screenshots, or graphics). The issue is reproducible on Chrome but not on Safari, likely due to differences in how each browser's EXIF parsing pipeline populates these values. This fix adds nullish coalescing fallbacks (`?? {}`) so that `Object.values()` always receives a valid object. * Fix optional chaining in getOffsetFromExif If `exif` itself is null/undefined, accessing `exif.tags` would throw before the `??` fallback kicks in. --- src/utility/exif.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utility/exif.ts b/src/utility/exif.ts index c1e9b335..a6eaa94f 100644 --- a/src/utility/exif.ts +++ b/src/utility/exif.ts @@ -16,8 +16,8 @@ export const getOffsetFromExif = ( exif: ExifData, exifr: any, ) => ( - Object.values(exif.tags as any).find(isValueOffset) || - Object.values(exifr).find(isValueOffset) + Object.values(exif?.tags ?? {}).find(isValueOffset) || + Object.values(exifr ?? {}).find(isValueOffset) ) as string | undefined; export const getDimensionsFromExif = (