{"record":{"id":"de9d04102140552e","repo":"immich-app/immich","slug":"thumbnail-generation-failed-for-asset-id-not-found-in","errorCode":null,"errorMessage":"Thumbnail generation failed for asset ${id}: not found in database or missing metadata","messagePattern":"Thumbnail generation failed for asset (.+?): not found in database or missing metadata","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/src/services/media.service.ts","lineNumber":160,"sourceCode":"    if (!asset) {\n      return JobStatus.Failed;\n    }\n\n    await this.storageCore.moveAssetImage(asset, AssetFileType.FullSize, image.fullsize.format);\n    await this.storageCore.moveAssetImage(asset, AssetFileType.Preview, image.preview.format);\n    await this.storageCore.moveAssetImage(asset, AssetFileType.Thumbnail, image.thumbnail.format);\n    await this.storageCore.moveAssetVideo(asset);\n\n    return JobStatus.Success;\n  }\n\n  @OnJob({ name: JobName.AssetEditThumbnailGeneration, queue: QueueName.Editor })\n  async handleAssetEditThumbnailGeneration({ id }: JobOf<JobName.AssetEditThumbnailGeneration>): Promise<JobStatus> {\n    const asset = await this.assetJobRepository.getForGenerateThumbnailJob(id);\n    const config = await this.getConfig({ withCache: true });\n\n    if (!asset) {\n      this.logger.warn(`Thumbnail generation failed for asset ${id}: not found in database or missing metadata`);\n      return JobStatus.Failed;\n    }\n\n    const generated = await this.generateEditedThumbnails(asset, config);\n    await this.syncFiles(\n      asset.files.filter((file) => file.isEdited),\n      generated?.files ?? [],\n    );\n\n    let thumbhash: Buffer | undefined = generated?.thumbhash;\n    if (!thumbhash) {\n      const extractedImage = await this.extractOriginalImage(asset, config.image);\n      const { info, data, colorspace } = extractedImage;\n\n      thumbhash = await this.mediaRepository.generateThumbhash(data, {\n        colorspace,\n        processInvalidImages: false,\n        raw: info,","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/server/src/services/media.service.ts#L142-L178","documentation":"The AssetEditThumbnailGeneration job handler loads the asset with the metadata required for thumbnail generation; when no row is found (or required relations/metadata are absent) it logs this warning and returns JobStatus.Failed. This prevents generating thumbnails for assets that were deleted or lack the needed data.","triggerScenarios":"An edit-thumbnail job is processed for an asset id that no longer exists, or getForGenerateThumbnailJob returns null because required joins (files/paths/exif) are missing for the edited asset.","commonSituations":"Asset deleted while an editor job was queued; editor queue replaying stale jobs after DB cleanup; job enqueued before the edited file was committed to the database.","solutions":["Check the asset exists with its edited files in the database; if deleted, ignore the failed job","Re-trigger thumbnail generation from the admin jobs UI after confirming the asset exists","Flush stale editor-queue jobs if they reference purged assets","If metadata is missing, re-run metadata extraction before the thumbnail job"],"exampleFix":"// before\nif (!asset) { this.logger.warn(`Thumbnail generation failed for asset ${id}: not found in database or missing metadata`); return JobStatus.Failed; }\n// after\nif (!asset) { this.logger.warn(`Thumbnail generation failed for asset ${id}: not found in database or missing metadata`); return JobStatus.Failed; }\n// remediation: re-run metadata extraction, then retry thumbnail generation","handlingStrategy":"validation","validationCode":"const asset = await assetJobRepository.getForGenerateThumbnailJob(id);\nif (!asset) return JobStatus.Failed; // skip; asset gone or metadata missing","typeGuard":null,"tryCatchPattern":"const asset = await this.assetJobRepository.getForGenerateThumbnailJob(id);\nif (!asset) { this.logger.warn(`Thumbnail generation failed for asset ${id}`); return JobStatus.Failed; }","preventionTips":["Run metadata extraction before thumbnail jobs","Flush editor queue after bulk asset deletions","Re-enqueue thumbnail jobs only after verifying the asset exists","Monitor repeated failures for one id as a sign of orphaned jobs"],"tags":["jobs","thumbnails","database"],"backgroundTag":"entity-not-found","analyzedSha":"e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c","analyzedAt":"2026-09-15T07:20:19.675Z","contentChangedAt":"2026-09-15T07:20:19.675Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}