hcengineering/platform · error

Failed to get metadata: ${err.message}

Error message

Failed to get metadata: ${err.message}

What it means

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.

Source

Thrown at pods/preview/src/providers/doc.ts:123

    return { mimeType: 'image/png', filePath: pngFile }
  }

  async metadata (
    ctx: MeasureContext,
    workspace: WorkspaceUuid,
    name: string,
    contentType: string
  ): Promise<PreviewMetadata> {
    const { filePath: path } = await ctx.with('thumbnail', {}, (ctx) => {
      return this.image(ctx, workspace, name, contentType)
    })

    try {
      const thumbnail = await getImageMetadata(ctx, path)
      return { thumbnail }
    } catch (err: any) {
      throw new Error(`Failed to get metadata: ${err.message}`)
    } finally {
      this.tempDir.rm(path)
    }
  }
}

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Read the inner err.message in 'Failed to get metadata: ...' to find the root cause
  2. Verify the source document opens correctly and is not corrupt or password-protected
  3. Ensure required conversion tools/dependencies are installed and on PATH
  4. Check temp directory space and permissions; inspect server logs from the underlying conversion step
Defensive patterns

Strategy: try-catch

Validate before calling

if (!isSupportedDocument(mimeType) || !(await fileIsReadable(path))) {
  // skip preview or return an unsupported-file placeholder
}

Type guard

function isPreviewableDocument (meta: { mime?: string; size?: number }): boolean {
  const ok = ['application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document']
  return typeof meta?.mime === 'string' && ok.includes(meta.mime) && (meta.size ?? 0) > 0
}

Try / catch

try {
  const { thumbnail } = await docProvider.metadata(ctx, file)
} catch (err) {
  ctx.warn('doc preview unavailable', { cause: err.message })
  return { thumbnail: defaultPlaceholder } // graceful fallback
}

Prevention

When it happens

Trigger: 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.

Common situations: Corrupt or password-protected documents; conversion binaries (libreoffice/imagemagick) missing or at unsupported versions; disk full in temp dir; oversized documents timing out.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/5a31e3f7b8dd80ba. Report an issue: GitHub.