fix: prevent server crash when extraction of metadata fails if the assets are corrupted (#26042)

* Fix-25968 Extraction of metadata fails if the assets are corrupted

* chore: clean up

---------

Co-authored-by: Jason Rasmussen <jason@rasm.me>
This commit is contained in:
Devansh H Jani
2026-02-19 02:23:23 +05:30
committed by GitHub
parent c4c7f94317
commit 2e59dbdc12

View File

@@ -38,6 +38,9 @@ import { isFaceImportEnabled } from 'src/utils/misc';
import { upsertTags } from 'src/utils/tag'; import { upsertTags } from 'src/utils/tag';
import { Tasks } from 'src/utils/tasks'; import { Tasks } from 'src/utils/tasks';
const POSTGRES_INT_MAX = 2_147_483_647;
const POSTGRES_INT_MIN = -2_147_483_648;
/** look for a date from these tags (in order) */ /** look for a date from these tags (in order) */
const EXIF_DATE_TAGS: Array<keyof ImmichTags> = [ const EXIF_DATE_TAGS: Array<keyof ImmichTags> = [
'SubSecDateTimeOriginal', 'SubSecDateTimeOriginal',
@@ -90,7 +93,10 @@ const validate = <T>(value: T): NonNullable<T> | null => {
return null; return null;
} }
if (typeof value === 'number' && (Number.isNaN(value) || !Number.isFinite(value))) { if (
typeof value === 'number' &&
(Number.isNaN(value) || !Number.isFinite(value) || value < POSTGRES_INT_MIN || value > POSTGRES_INT_MAX)
) {
return null; return null;
} }