{"record":{"id":"c3d982e8a806214f","repo":"temporalio/temporal","slug":"errunabletoexecuteactivity","errorCode":"ErrUnableToExecuteActivity","errorMessage":"%w: AddESMappingFieldActivity: %v","messagePattern":"%w: AddESMappingFieldActivity: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/worker/addsearchattributes/workflow.go","lineNumber":93,"sourceCode":"\tErrUnableToGetSearchAttributes  = errors.New(\"unable to get search attributes from cluster metadata\")\n\tErrUnableToSaveSearchAttributes = errors.New(\"unable to save search attributes to cluster metadata\")\n)\n\n// AddSearchAttributesWorkflow is the workflow that adds search attributes to the cluster for specific index.\nfunc AddSearchAttributesWorkflow(ctx workflow.Context, params WorkflowParams) error {\n\tlogger := workflow.GetLogger(ctx)\n\tlogger.Info(\"Workflow started.\", tag.WorkflowType(WorkflowName))\n\n\tctx = workflow.WithTaskQueue(ctx, primitives.AddSearchAttributesActivityTQ)\n\n\tvar a *activities\n\tvar err error\n\n\tif !params.SkipSchemaUpdate {\n\t\tctx1 := workflow.WithActivityOptions(ctx, addESMappingFieldActivityOptions)\n\t\terr = workflow.ExecuteActivity(ctx1, a.AddESMappingFieldActivity, params).Get(ctx, nil)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%w: AddESMappingFieldActivity: %v\", ErrUnableToExecuteActivity, err)\n\t\t}\n\n\t\tctx2 := workflow.WithActivityOptions(ctx, waitForYellowStatusActivityOptions)\n\t\terr = workflow.ExecuteActivity(ctx2, a.WaitForYellowStatusActivity, params.IndexName).Get(ctx, nil)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%w: WaitForYellowStatusActivity: %v\", ErrUnableToExecuteActivity, err)\n\t\t}\n\t}\n\n\tctx3 := workflow.WithActivityOptions(ctx, updateClusterMetadataActivityOptions)\n\terr = workflow.ExecuteActivity(ctx3, a.UpdateClusterMetadataActivity, params).Get(ctx, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%w: UpdateClusterMetadataActivity: %v\", ErrUnableToExecuteActivity, err)\n\t}\n\n\tlogger.Info(\"Workflow finished successfully.\", tag.WorkflowType(WorkflowName))\n\treturn nil\n}","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/worker/addsearchattributes/workflow.go#L75-L111","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Read the wrapped inner error (%v) to identify the root cause (connection refused, mapping conflict, timeout)","Verify Elasticsearch connectivity and credentials in the worker service config (persistence/visibility settings)","If a mapping type conflict, either remove the conflicting attribute from the request or fix the existing index mapping / reindex","Retry the workflow — adding attributes is idempotent per attribute; check the temporal-sys/add_search_attributes workflow history for the activity failure details"],"exampleFix":"// before: adding an attribute whose type conflicts with ES mapping\nAddSearchAttributesParams{SearchAttributes: {\"CustomInt\": \"Int\"}} // index already maps CustomInt as Keyword\n\n// after: choose a non-conflicting name or correct type\nAddSearchAttributesParams{SearchAttributes: {\"CustomInt2\": \"Int\"}}","handlingStrategy":"try-catch","validationCode":"// Before starting the workflow: verify ES is reachable and attribute types are valid\nfor name, typ := range params.SearchAttributes {\n\tif !validESMappingTypes[typ] {\n\t\treturn fmt.Errorf(\"invalid attribute type %q for %q\", typ, name)\n\t}\n}\n// plus a health check: GET /_cluster/health must not be red","typeGuard":null,"tryCatchPattern":"err = workflow.ExecuteActivity(ctx1, a.AddESMappingFieldActivity, params).Get(ctx, nil)\nif err != nil {\n\tlogger.Error(\"AddESMappingFieldActivity failed; check ES connectivity and mapping conflicts\",\n\t\ttag.Error(err))\n\treturn fmt.Errorf(\"%w: AddESMappingFieldActivity: %v\", ErrUnableToExecuteActivity, err)\n}","preventionTips":["Verify Elasticsearch connectivity/credentials from worker hosts before running the workflow","Avoid adding attributes whose names/types conflict with existing ES mappings","Run one add-search-attributes workflow at a time","Check activity failure details in workflow history before retrying"],"tags":["go","elasticsearch","search-attributes","activity-failure","system-workflow"],"backgroundTag":"activity-execution-failed","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}