Metadata extraction jobs need better error handling #808

Closed
opened 2026-02-04 22:47:55 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @bo0tzz on GitHub (Apr 10, 2023).

Both the image exif and video metadata jobs need better error handling. Currently, both are wrapped in one big try/catch that just gives up on any errors. Meanwhile, any bad data that doesn't cause an immediate exception isn't validated well and causes an error on database insert:

ERROR [MetadataExtractionProcessor] Error extracting EXIF QueryFailedError: invalid input syntax for type timestamp with time zone: "0NaN-NaN-NaNTNaN:NaN:NaN.NaN+NaN:NaN"
QueryFailedError: invalid input syntax for type timestamp with time zone: "0NaN-NaN-NaNTNaN:NaN:NaN.NaN+NaN:NaN"
    at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19)
(...)

Another problem is that these jobs are responsible for saving the original filename as passed in the asset upload call. If these jobs fail, that filename is lost.

This needs some refactoring so that

  1. Better data validation is performed.
  2. A best-effort attempt is made to still save whatever data can be saved to the database when an error occurs.
  3. All errors are clearly logged with relevant (asset) IDs and, where applicable, actionable error messages.
Originally created by @bo0tzz on GitHub (Apr 10, 2023). Both the [image exif](https://github.com/immich-app/immich/blob/main/server/apps/microservices/src/processors/metadata-extraction.processor.ts#L92) and [video metadata](https://github.com/immich-app/immich/blob/main/server/apps/microservices/src/processors/metadata-extraction.processor.ts#L192) jobs need better error handling. Currently, both are wrapped in one big try/catch that just gives up on any errors. Meanwhile, any bad data that doesn't cause an immediate exception isn't validated well and causes an error on database insert: ``` ERROR [MetadataExtractionProcessor] Error extracting EXIF QueryFailedError: invalid input syntax for type timestamp with time zone: "0NaN-NaN-NaNTNaN:NaN:NaN.NaN+NaN:NaN" QueryFailedError: invalid input syntax for type timestamp with time zone: "0NaN-NaN-NaNTNaN:NaN:NaN.NaN+NaN:NaN" at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19) (...) ``` Another problem is that these jobs are responsible for saving the original filename as passed in the asset upload call. If these jobs fail, that filename is lost. This needs some refactoring so that 1. Better data validation is performed. 2. A best-effort attempt is made to still save whatever data can be saved to the database when an error occurs. 3. All errors are clearly logged with relevant (asset) IDs and, where applicable, actionable error messages.
OVERLORD added the 🗄️servertech-debt labels 2026-02-04 22:47:55 +03:00
Author
Owner

@samip5 commented on GitHub (Apr 11, 2023):

I don't think #2230 addressed 1 nor 2 points.

@samip5 commented on GitHub (Apr 11, 2023): I don't think #2230 addressed 1 nor 2 points.
Author
Owner

@uhthomas commented on GitHub (Jul 9, 2023):

Should be resolved by #2908.

@uhthomas commented on GitHub (Jul 9, 2023): Should be resolved by #2908.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#808