temporalio/temporal · error

unknown admin batch type: %T

Error message

unknown admin batch type: %T

What it means

processAdminTask dispatches an admin batch request based on the Go type of adminReq.Operation via a type switch. When the operation's concrete type does not match any known admin batch operation (e.g. RefreshWorkflowTasks), the default branch throws this error. It indicates the batcher was given an admin operation type it does not implement.

Source

Thrown at service/worker/batcher/activities.go:956

	case *adminservice.StartAdminBatchOperationRequest_RefreshTasksOperation:
		return processTask(ctx, limiter, task,
			func(executionInfo *workflowpb.WorkflowExecutionInfo) error {
				archetypeID, err := workercommon.ArchetypeIDFromExecutionInfo(executionInfo)
				if err != nil {
					return fmt.Errorf("archetypeID extraction error: %w", err)
				}
				_, err = a.HistoryClient.RefreshWorkflowTasks(ctx, &historyservice.RefreshWorkflowTasksRequest{
					NamespaceId: batchOperation.NamespaceId,
					ArchetypeId: uint32(archetypeID),
					Request: &adminservice.RefreshWorkflowTasksRequest{
						NamespaceId: batchOperation.NamespaceId,
						Execution:   executionInfo.Execution,
					},
				})
				return err
			})
	default:
		return fmt.Errorf("unknown admin batch type: %T", adminReq.Operation)
	}
}

func processTask(
	ctx context.Context,
	limiter quotas.RequestRateLimiter,
	task task,
	procFn func(*workflowpb.WorkflowExecutionInfo) error,
) error {
	err := limiter.Wait(ctx, batchQuotaRequest)
	if err != nil {
		return err
	}

	err = procFn(task.executionInfo)
	if err != nil {
		// NotFound means wf is not running or deleted
		if !common.IsNotFoundError(err) {

View on GitHub (pinned to bde624efd1)

Solutions

  1. Check the concrete type of the Operation being sent and use only admin batch types supported by this batcher version (e.g. RefreshWorkflowTasks).
  2. Align worker and server versions: upgrade the batcher worker so its type switch covers any newly introduced admin batch operation types.
  3. If you own the code, add a case to the type switch in processAdminTask handling the missing operation type.
  4. Log/inspect %T in the error to identify exactly which type was passed and trace where it was constructed.

Example fix

// before
switch adminReq.Operation.(type) {
case *batchspb.BatchOperationInput: ...
default:
  return fmt.Errorf("unknown admin batch type: %T", adminReq.Operation)
}
// after
switch adminReq.Operation.(type) {
case *batchspb.BatchOperationInput: ...
case *adminspb.RefreshWorkflowTasksRequest: // newly supported type
  ...
default:
  return fmt.Errorf("unknown admin batch type: %T", adminReq.Operation)
}
Defensive patterns

Strategy: type-guard

Validate before calling

// validate the admin op before dispatch
if adminReq.GetOperation() == nil {
  return fmt.Errorf("admin batch operation is unset")
}
switch adminReq.Operation.(type) {
case *batchspb.BatchOperationInput:
  // supported
default:
  return fmt.Errorf("unsupported admin batch type %T; upgrade worker", adminReq.Operation)
}

Type guard

func isAdminBatchOpSupported(op interface{}) bool {
  switch op.(type) {
  case *batchspb.BatchOperationInput:
    return true
  default:
    return false
  }
}

Try / catch

if err := batcher.ProcessAdminTask(ctx, adminReq); err != nil {
  if strings.Contains(err.Error(), "unknown admin batch type") {
    logger.Error("batcher does not support this admin op; upgrade worker", tag.Error(err))
    return
  }
  return err
}

Prevention

When it happens

Trigger: Calling the batcher's admin task path (processAdminTask, reached via processSingleTask) with an adminReq whose Operation field holds an admin batch type not handled by the switch — for example a newly added admin operation type, or a nil/wrongly-constructed operation payload.

Common situations: Deploying a new Temporal version where the frontend emits an admin batch type the worker's batcher does not yet support; misconfigured batch admin tooling sending the wrong operation enum; tests like TestProcessAdminTask_UnknownOperation exercising the unknown-op path.

Related errors


AI-assisted analysis of temporalio/temporal@bde624efd1 (2026-09-01). Data as JSON: /api/errors/1f08f56312e232e4. Report an issue: GitHub.