temporalio/temporal · error

ErrUnableToExecuteActivity

ErrUnableToExecuteActivity

Error message

%w: AddESMappingFieldActivity: %v

What it means

The AddSearchAttributes system workflow executes AddESMappingFieldActivity to add new search attribute fields to the Elasticsearch index mapping. When that activity fails, the workflow returns ErrUnableToExecuteActivity wrapped with the activity error. Any activity failure (schema update error, ES client error, timeout) surfaces here.

Source

Thrown at service/worker/addsearchattributes/workflow.go:93

	ErrUnableToGetSearchAttributes  = errors.New("unable to get search attributes from cluster metadata")
	ErrUnableToSaveSearchAttributes = errors.New("unable to save search attributes to cluster metadata")
)

// AddSearchAttributesWorkflow is the workflow that adds search attributes to the cluster for specific index.
func AddSearchAttributesWorkflow(ctx workflow.Context, params WorkflowParams) error {
	logger := workflow.GetLogger(ctx)
	logger.Info("Workflow started.", tag.WorkflowType(WorkflowName))

	ctx = workflow.WithTaskQueue(ctx, primitives.AddSearchAttributesActivityTQ)

	var a *activities
	var err error

	if !params.SkipSchemaUpdate {
		ctx1 := workflow.WithActivityOptions(ctx, addESMappingFieldActivityOptions)
		err = workflow.ExecuteActivity(ctx1, a.AddESMappingFieldActivity, params).Get(ctx, nil)
		if err != nil {
			return fmt.Errorf("%w: AddESMappingFieldActivity: %v", ErrUnableToExecuteActivity, err)
		}

		ctx2 := workflow.WithActivityOptions(ctx, waitForYellowStatusActivityOptions)
		err = workflow.ExecuteActivity(ctx2, a.WaitForYellowStatusActivity, params.IndexName).Get(ctx, nil)
		if err != nil {
			return fmt.Errorf("%w: WaitForYellowStatusActivity: %v", ErrUnableToExecuteActivity, err)
		}
	}

	ctx3 := workflow.WithActivityOptions(ctx, updateClusterMetadataActivityOptions)
	err = workflow.ExecuteActivity(ctx3, a.UpdateClusterMetadataActivity, params).Get(ctx, nil)
	if err != nil {
		return fmt.Errorf("%w: UpdateClusterMetadataActivity: %v", ErrUnableToExecuteActivity, err)
	}

	logger.Info("Workflow finished successfully.", tag.WorkflowType(WorkflowName))
	return nil
}

View on GitHub (pinned to bde624efd1)

Solutions

  1. Read the wrapped inner error (%v) to identify the root cause (connection refused, mapping conflict, timeout)
  2. Verify Elasticsearch connectivity and credentials in the worker service config (persistence/visibility settings)
  3. If a mapping type conflict, either remove the conflicting attribute from the request or fix the existing index mapping / reindex
  4. Retry the workflow — adding attributes is idempotent per attribute; check the temporal-sys/add_search_attributes workflow history for the activity failure details

Example fix

// before: adding an attribute whose type conflicts with ES mapping
AddSearchAttributesParams{SearchAttributes: {"CustomInt": "Int"}} // index already maps CustomInt as Keyword

// after: choose a non-conflicting name or correct type
AddSearchAttributesParams{SearchAttributes: {"CustomInt2": "Int"}}
Defensive patterns

Strategy: try-catch

Validate before calling

// Before starting the workflow: verify ES is reachable and attribute types are valid
for name, typ := range params.SearchAttributes {
	if !validESMappingTypes[typ] {
		return fmt.Errorf("invalid attribute type %q for %q", typ, name)
	}
}
// plus a health check: GET /_cluster/health must not be red

Try / catch

err = workflow.ExecuteActivity(ctx1, a.AddESMappingFieldActivity, params).Get(ctx, nil)
if err != nil {
	logger.Error("AddESMappingFieldActivity failed; check ES connectivity and mapping conflicts",
		tag.Error(err))
	return fmt.Errorf("%w: AddESMappingFieldActivity: %v", ErrUnableToExecuteActivity, err)
}

Prevention

When it happens

Trigger: Running the add-search-attributes workflow with SkipSchemaUpdate=false and the AddESMappingFieldActivity fails — e.g. Elasticsearch unreachable, mapping conflict, invalid attribute type, or activity timeout (addESMappingFieldActivityOptions).

Common situations: Elasticsearch cluster down or misconfigured ES URL/credentials in dynamicconfig; attempting to add an attribute with a type conflicting with the existing mapping; ES version incompatibilities; network/firewall blocking the worker service from ES.

Related errors


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