immich-app/immich · error · Error
authToken is required
Error message
authToken is required
What it means
A plain Error thrown inside the wrap() host-function dispatcher when the JSON input read from the plugin handle does not contain an authToken field. The wrap function reads the handle, parses { authToken, args }, and requires a truthy authToken before validating it as a JWT. Without it, the call is rejected before any authentication attempt.
Source
Thrown at server/src/services/workflow-execution.service.ts:170
}
private getPluginKey({ id, hostFunctions }: { id: string; hostFunctions: boolean }) {
return id + (hostFunctions ? '/worker' : '');
}
private wrap<T>(fn: (authDto: AuthDto, context: HostContext, args: T) => Promise<unknown>) {
return async (plugin: CurrentPlugin, offset: bigint) => {
try {
const handle = plugin.read(offset);
if (!handle) {
return plugin.store(
JSON.stringify({ success: false, status: 400, message: 'Called host function without input' }),
);
}
const { authToken, args } = handle.json() as { authToken: string; args: T };
if (!authToken) {
throw new Error('authToken is required');
}
const context = plugin.hostContext<HostContext>();
const authDto = this.validate(authToken);
const response = await fn(authDto, context, args);
return plugin.store(JSON.stringify({ success: true, response }));
} catch (error: Error | any) {
if (error instanceof HttpException) {
this.logger.error(`Plugin host exception: ${error}`);
return plugin.store(
JSON.stringify({ success: false, status: error.getStatus(), message: error.getResponse() }),
);
}
this.logger.error(`Plugin host exception: ${error}`, error?.stack);
return plugin.store(View on GitHub (pinned to 199723261c)
Solutions
- Ensure the plugin reads workflow.authToken from the WorkflowEventPayload and includes it in every host function call input.
- Update the plugin SDK to a version that injects authToken automatically.
- Validate, in plugin tests, that host call inputs contain a non-empty authToken before dispatch.
- Rebuild and re-import the WASM plugin after fixing the SDK wiring.
Example fix
// before (plugin pseudo-code)
const result = host.call('searchAlbums', JSON.stringify({ args: [dto] }));
// after
const result = host.call('searchAlbums', JSON.stringify({ authToken: payload.workflow.authToken, args: [dto] })); Defensive patterns
Strategy: validation
Validate before calling
// Plugin-side: ensure authToken is present before any host call
function buildHostInput(payload, args) {
if (!payload?.workflow?.authToken) {
throw new Error('authToken missing from workflow payload');
}
return { authToken: payload.workflow.authToken, args };
} Type guard
const hasAuthToken = (input: unknown): input is { authToken: string } =>
typeof input === 'object' && input !== null && typeof (input as any).authToken === 'string' && (input as any).authToken.length > 0; Try / catch
// On the server wrap() this becomes a failure response; detect it in the plugin
const result = host.call('searchAlbums', JSON.stringify(buildHostInput(payload, args)));
if (!result.success && result.message === 'authToken is required') {
abortWorkflow('authToken not propagated');
} Prevention
- Always forward payload.workflow.authToken into host-call inputs.
- Keep the plugin SDK updated so authToken injection is automatic.
- Add a plugin unit test asserting host inputs contain a non-empty authToken.
When it happens
Trigger: A plugin calls a host function (searchAlbums, createAlbum, httpRequest, etc.) but the input payload it writes to memory omits authToken. This usually means the plugin SDK code did not forward the workflow authToken from the WorkflowEventPayload into the host call input.
Common situations: Plugin SDK integration bug where the payload's workflow.authToken is not propagated; plugin authored against an older SDK that did not require authToken; manually constructed host-call input missing the field.
Related errors
- Calling host functions is not allowed without setting method
- Failed to call host function "${String(name)}", received ${r
- Invalid token: missing userId
- Invalid token
- Plugin not found
AI-assisted analysis of immich-app/immich@199723261c (2026-08-12).
Data as JSON: /api/errors/ce9264eeaf259a72.
Report an issue: GitHub.