{"record":{"id":"c51758ea038de26e","repo":"hcengineering/platform","slug":"failed-to-get-metadata-err-message-c51758","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/video.ts","lineNumber":67,"sourceCode":"\n    return { mimeType: 'image/png', filePath: pngFile }\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('thumbnail', {}, (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":49,"sourceCodeEnd":73,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/pods/preview/src/providers/video.ts#L49-L73","documentation":"The video provider's metadata() extracts a thumbnail frame from the video (via image()) and then reads the resulting PNG's dimensions with getImageMetadata (sharp). This error wraps any failure of that read — typically the frame extraction failed so the file is missing/invalid, or sharp cannot parse the produced image. The underlying err.message is appended.","triggerScenarios":"Requesting metadata for a video blob whose thumbnail frame could not be extracted (unsupported codec, ffmpeg missing or failed, zero-length video), yielding a missing or corrupt temp image passed to sharp.","commonSituations":"Host without ffmpeg on PATH, exotic codecs (e.g. HEVC/AV1) ffmpeg build can't decode, corrupted uploads, disk-full producing truncated frame files.","solutions":["Check the wrapped err.message to distinguish 'file not found' (extraction failed) from 'unsupported image format'.","Install/verify ffmpeg on the preview host so video frame extraction succeeds.","Verify the video plays/has a decodable first frame; re-upload a valid file if corrupted.","Check disk space and temp file permissions."],"exampleFix":"// before\nthrow new Error(`Failed to get metadata: ${err.message}`)\n// after\nctx.error('video metadata failed', { cause: err.message })\nthrow new Error(`Failed to get metadata: ${err.message}`)","handlingStrategy":"try-catch","validationCode":"const stat = await storage.stat(ctx, { uuid: workspace }, name)\nif (stat === undefined || !stat.contentType.startsWith('video/')) return null","typeGuard":"function isVideoBlob(stat): stat is Blob {\n  return stat != null && typeof stat.contentType === 'string' && stat.contentType.startsWith('video/')\n}","tryCatchPattern":"try {\n  const meta = await preview.metadata(ctx, workspace, name)\n} catch (err) {\n  if (String(err.message).startsWith('Failed to get metadata:')) {\n    ctx.warn('video preview metadata unavailable', { name, cause: err.message })\n    return { thumbnail: undefined }\n  }\n  throw err\n}","preventionTips":["Verify ffmpeg exists on the host at service startup.","Restrict accepted video codecs/formats at upload.","Check the extracted frame file exists before reading metadata.","Monitor temp dir disk usage."],"tags":["preview","video","ffmpeg","sharp"],"backgroundTag":"image-metadata-extraction-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}