{"record":{"id":"a2beb04402499d00","repo":"hcengineering/platform","slug":"failed-to-get-metadata-err-message-a2beb0","errorCode":null,"errorMessage":"Failed to get metadata: ${err.message}","messagePattern":"Failed to get metadata: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pods/preview/src/providers/image.ts","lineNumber":77,"sourceCode":"\n    return { mimeType: contentType, filePath: path }\n  }\n\n  async metadata (\n    ctx: MeasureContext,\n    workspace: WorkspaceUuid,\n    name: string,\n    contentType: string\n  ): Promise<PreviewMetadata> {\n    const { filePath: path } = await ctx.with('image', { contentType }, (ctx) => {\n      return this.image(ctx, workspace, name, contentType)\n    })\n\n    try {\n      const thumbnail = await getImageMetadata(ctx, path)\n      return { thumbnail }\n    } catch (err: any) {\n      throw new Error(`Failed to get metadata: ${err.message}`)\n    } finally {\n      this.tempDir.rm(path)\n    }\n  }\n}\n","sourceCodeStart":59,"sourceCodeEnd":83,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/pods/preview/src/providers/image.ts#L59-L83","documentation":"The image provider's metadata method calls getImageMetadata on the stored image path to build a thumbnail. Failures from getImageMetadata are wrapped and rethrown as 'Failed to get metadata: <err.message>'; the temp file is always cleaned up in finally.","triggerScenarios":"metadata() on an image when getImageMetadata throws — invalid/unsupported image data, truncated file, unsupported format by the processing library, or IO errors on the temp path.","commonSituations":"Users upload files that aren't actually valid images (wrong extension); unsupported formats (HEIC, exotic TIFFs); zero-byte or truncated uploads; image library lacking format support.","solutions":["Inspect the inner err.message in 'Failed to get metadata: ...' for the concrete cause","Validate the upload is a real image (magic-byte sniffing) before preview processing","Convert unsupported formats (e.g. HEIC) to JPEG/PNG before preview","Check available temp disk space and that the image processing dependencies are installed"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if (!(await hasValidImageMagicBytes(path))) {\n  // treat as non-image: skip preview generation\n}","typeGuard":"function isPreviewableImage (meta: { mime?: string; size?: number }): boolean {\n  const ok = ['image/jpeg', 'image/png', 'image/gif', 'image/webp']\n  return typeof meta?.mime === 'string' && ok.includes(meta.mime) && (meta.size ?? 0) > 0\n}","tryCatchPattern":"try {\n  const { thumbnail } = await imageProvider.metadata(ctx, file)\n} catch (err) {\n  ctx.warn('image preview failed', { cause: err.message })\n  return { thumbnail: genericImagePlaceholder }\n}","preventionTips":["Sniff magic bytes on upload instead of trusting extensions","Accept-list supported image formats and convert exotic ones (HEIC) upstream","Keep the image processing library updated with format support","Serve a generic placeholder when preview generation fails so UIs degrade gracefully"],"tags":["image","preview","metadata"],"backgroundTag":"metadata-extraction-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}