hcengineering/platform · error
Failed to get metadata: ${err.message}
Error message
Failed to get metadata: ${err.message} What it means
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.
Source
Thrown at pods/preview/src/providers/image.ts:77
return { mimeType: contentType, filePath: path }
}
async metadata (
ctx: MeasureContext,
workspace: WorkspaceUuid,
name: string,
contentType: string
): Promise<PreviewMetadata> {
const { filePath: path } = await ctx.with('image', { contentType }, (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
- 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
Defensive patterns
Strategy: fallback
Validate before calling
if (!(await hasValidImageMagicBytes(path))) {
// treat as non-image: skip preview generation
} Type guard
function isPreviewableImage (meta: { mime?: string; size?: number }): boolean {
const ok = ['image/jpeg', 'image/png', 'image/gif', 'image/webp']
return typeof meta?.mime === 'string' && ok.includes(meta.mime) && (meta.size ?? 0) > 0
} Try / catch
try {
const { thumbnail } = await imageProvider.metadata(ctx, file)
} catch (err) {
ctx.warn('image preview failed', { cause: err.message })
return { thumbnail: genericImagePlaceholder }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to get metadata: ${err.message}
- WorkspaceUuid is not defined
- Calendar service URL or token is not defined
- Accounts URL or token is not defined
- Accounts URL or token is not defined
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/a2beb04402499d00.
Report an issue: GitHub.