{"record":{"id":"5a31e3f7b8dd80ba","repo":"hcengineering/platform","slug":"failed-to-get-metadata-err-message","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/doc.ts","lineNumber":123,"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":105,"sourceCodeEnd":129,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/pods/preview/src/providers/doc.ts#L105-L129","documentation":"The doc provider's metadata method renders a document to an image and calls getImageMetadata to produce a thumbnail. Any failure inside getImageMetadata (rendering, conversion, IO) is wrapped and rethrown as 'Failed to get metadata: <err.message>'. The temp file is removed in finally.","triggerScenarios":"metadata() on a document when getImageMetadata fails — e.g. the doc-to-image conversion pipeline errors, the temp image is invalid, or the underlying tool is missing/crashes.","commonSituations":"Corrupt or password-protected documents; conversion binaries (libreoffice/imagemagick) missing or at unsupported versions; disk full in temp dir; oversized documents timing out.","solutions":["Read the inner err.message in 'Failed to get metadata: ...' to find the root cause","Verify the source document opens correctly and is not corrupt or password-protected","Ensure required conversion tools/dependencies are installed and on PATH","Check temp directory space and permissions; inspect server logs from the underlying conversion step"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!isSupportedDocument(mimeType) || !(await fileIsReadable(path))) {\n  // skip preview or return an unsupported-file placeholder\n}","typeGuard":"function isPreviewableDocument (meta: { mime?: string; size?: number }): boolean {\n  const ok = ['application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document']\n  return typeof meta?.mime === 'string' && ok.includes(meta.mime) && (meta.size ?? 0) > 0\n}","tryCatchPattern":"try {\n  const { thumbnail } = await docProvider.metadata(ctx, file)\n} catch (err) {\n  ctx.warn('doc preview unavailable', { cause: err.message })\n  return { thumbnail: defaultPlaceholder } // graceful fallback\n}","preventionTips":["Parse the wrapped inner message ('Failed to get metadata: X') to find the true root cause","Install and version-pin conversion binaries and verify them at startup","Monitor temp disk space where previews are rendered","Reject corrupt or encrypted documents at upload time"],"tags":["document","preview","metadata"],"backgroundTag":"metadata-extraction-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}