immich-app/immich · error · Error
Failed to call host function
Error message
Failed to call host function "${String(name)}", received ${result.status} - ${JSON.stringify(result.message)} What it means
In the Immich plugin SDK, plugin code invokes a host function (exposed by the app runtime over WASM) and the host returns a serialized HostFunctionResult with success=false. The SDK throws with the function name plus the host-provided status and message, telling the plugin author the host-side call failed (not the SDK call mechanics).
Solutions
- Read result.status/message in the error text; it names the host-side cause (missing permission, bad argument, unknown function).
- Align plugin SDK version with the host Immich version and rebuild the plugin.
- Validate the arguments/DTO passed to the host function against the SDK types.
- Confirm the plugin runs in the intended context (user session/admin) that grants the function.
Example fix
// before
await hostFunctions.getAssetById(id); // throws if host rejects
// after
try {
await hostFunctions.getAssetById(id);
} catch (e) {
log(`host call failed: ${e.message}`); // surface status + message from host
} Defensive patterns
Strategy: try-catch
Validate before calling
// pin matching SDK + host versions at build time assert(pluginSdkVersion === hostImmichVersion, 'SDK/host version mismatch');
Try / catch
try {
const res = await hostFunctions.someCall(args);
} catch (e) {
const { status, message } = parseHostError(e.message);
if (status === 403) requestPermissionAndRetry();
else if (status === 404) disableFeature();
else throw e;
} Prevention
- Keep plugin SDK version aligned with the target Immich host version
- Validate DTO arguments with SDK types before host calls
- Check required permissions/session context for the function used
When it happens
Trigger: Calling any hostFunctions.* method from a plugin when the host rejects it: e.g. requesting a function not exposed by the current host version, passing arguments the host validates and rejects, or the host lacking permission/context for the operation.
Common situations: Running a plugin built against a newer SDK on an older Immich host, calling user-scoped functions without the required user session, or passing malformed DTOs to host functions like asset search.
Related errors
AI-assisted analysis of immich-app/immich@e55ac299a4 (2026-09-15).
Data as JSON: /api/errors/0e8a47f90434141f.
Report an issue: GitHub.
Appendix: source
Thrown at packages/plugin-sdk/src/host-functions.ts:71
] as const;
export const hostFunctions = (authToken: string) => {
const host = Host.getFunctions();
type HostFunctionName = keyof typeof host;
const call = <T, R>(name: HostFunctionName, authToken: string, args: T) => {
const pointer1 = Memory.fromString(JSON.stringify({ authToken, args }));
const fn = host[name];
const handler = Memory.find(fn(pointer1.offset));
try {
const result = JSON.parse(handler.readString()) as HostFunctionResult<R>;
if (result.success) {
return result.response;
}
throw new Error(
`Failed to call host function "${String(name)}", received ${result.status} - ${JSON.stringify(result.message)}`,
);
} finally {
handler.free();
pointer1.free();
}
};
return {
// album
searchAlbums: (dto: AlbumSearchDto) =>
call<[AlbumSearchDto], AlbumResponseDto[]>('searchAlbums', authToken, [
dto,
]),
createAlbum: (dto: CreateAlbumDto) =>
call<[CreateAlbumDto], AlbumResponseDto>('createAlbum', authToken, [dto]),
addAssetsToAlbum: (albumId: string, assetIds: string[]) =>
call<[string, BulkIdsDto], BulkIdResponseDto[]>(View on GitHub (pinned to e55ac299a4)