immich-app/immich · error · Error

Unable to infer workflow event type from steps

Error message

Unable to infer workflow event type from steps

What it means

A plain Error thrown by WorkflowExecutionService.execute when no single WorkflowType is common to all workflow steps. The inference loop checks each WorkflowType value and asks whether any step lacks that type in its step.types; if none of the WorkflowType values are present in every step, the workflow cannot be run and the job fails.

Source

Thrown at server/src/services/workflow-execution.service.ts:393

    getHandler: (type: T) => ExecuteOptions<T> | undefined,
  ) {
    const workflow = await this.workflowRepository.getForWorkflowRun(workflowId);
    if (!workflow) {
      return;
    }

    // TODO infer from steps
    let type: T | undefined;
    for (const targetType of Object.values(WorkflowType)) {
      const isMissing = workflow.steps.some((step) => !step.types.includes(targetType));
      if (!isMissing) {
        type = targetType as unknown as T;
        break;
      }
    }

    if (!type) {
      throw new Error('Unable to infer workflow event type from steps');
    }

    const handler = getHandler(type);
    if (!handler) {
      this.logger.error(`Misconfigured workflow ${workflowId}: no handler for type ${type}`);
      return;
    }

    try {
      const { read, write } = handler;
      const readResult = await read(type);
      let data = readResult.data;
      for (const step of workflow.steps) {
        const payload: WorkflowEventPayload<typeof type> = {
          trigger: workflow.trigger,
          type,
          config: step.config ?? {},
          workflow: {

View on GitHub (pinned to 199723261c)

Solutions

  1. Edit the workflow so every step's method declares at least one WorkflowType in common with the others (today, typically AssetV1).
  2. Replace or remove the offending step whose types do not include the common type.
  3. Re-validate the workflow via the create/update endpoint which runs resolveAndValidateSteps before persistence.
  4. After fixing, re-trigger the workflow run.

Example fix

// before: step A types=[AssetV1], step B types=[AssetPersonV1] -> no common type
// after: replace step B with a method whose types include AssetV1
Defensive patterns

Strategy: validation

Validate before calling

function findCommonWorkflowType(steps) {
  const allTypes = Object.values(WorkflowType);
  return allTypes.find((t) => steps.every((s) => s.types.includes(t)));
}
const common = findCommonWorkflowType(steps);
if (!common) {
  return { ok: false, reason: 'No common WorkflowType across steps' };
}

Type guard

const isWorkflowTypeInferenceError = (e: unknown): boolean =>
  typeof e === 'object' && e !== null && typeof (e as any).message === 'string' &&
  (e as any).message.includes('Unable to infer workflow event type');

Try / catch

// This error fails the workflow job; catch at the runner boundary
try {
  await runWorkflow(workflowId);
} catch (e) {
  if (isWorkflowTypeInferenceError(e)) {
    notifyAdminToFixWorkflowSteps(workflowId);
  }
}

Prevention

When it happens

Trigger: A workflow was created or updated with steps whose declared types do not intersect (e.g., one step supports AssetV1 and another supports a future AssetPersonV1 that AssetV1 does not cover). The TODO comment notes inference is temporary, so misconfigured combinations reach this branch.

Common situations: Mixing plugin methods that declare incompatible WorkflowType sets; plugin upgraded to declare new types that no longer overlap; manually editing workflow steps in the DB to add an incompatible method.

Related errors


AI-assisted analysis of immich-app/immich@199723261c (2026-08-12). Data as JSON: /api/errors/54f9148419b123ab. Report an issue: GitHub.