{"record":{"id":"a6be9e0c0a38fe12","repo":"temporalio/temporal","slug":"errunabletoupdateesmapping","errorCode":"ErrUnableToUpdateESMapping","errorMessage":"%w: %v","messagePattern":"%w: %v","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/worker/addsearchattributes/workflow.go","lineNumber":126,"sourceCode":"\n\tlogger.Info(\"Workflow finished successfully.\", tag.WorkflowType(WorkflowName))\n\treturn nil\n}\n\nfunc (a *activities) AddESMappingFieldActivity(ctx context.Context, params WorkflowParams) error {\n\tif a.esClient == nil {\n\t\ta.logger.Info(\"Elasticsearch client is not configured. Skipping mapping update.\")\n\t\treturn nil\n\t}\n\n\ta.logger.Info(\"Creating Elasticsearch mapping.\", tag.ESIndex(params.IndexName), tag.ESMapping(params.CustomAttributesToAdd))\n\t_, err := a.esClient.PutMapping(ctx, params.IndexName, params.CustomAttributesToAdd)\n\tif err != nil {\n\t\tmetrics.AddSearchAttributesFailuresCount.With(a.metricsHandler).Record(1)\n\n\t\tif a.isRetryableError(err) {\n\t\t\ta.logger.Error(\"Unable to update Elasticsearch mapping (retryable error).\", tag.ESIndex(params.IndexName), tag.Error(err))\n\t\t\treturn fmt.Errorf(\"%w: %v\", ErrUnableToUpdateESMapping, err)\n\t\t}\n\t\ta.logger.Error(\"Unable to update Elasticsearch mapping (non-retryable error).\", tag.ESIndex(params.IndexName), tag.Error(err))\n\t\treturn temporal.NewNonRetryableApplicationError(fmt.Sprintf(\"%v: %v\", ErrUnableToUpdateESMapping, err), \"\", nil)\n\t}\n\ta.logger.Info(\"Elasticsearch mapping created.\", tag.ESIndex(params.IndexName), tag.ESMapping(params.CustomAttributesToAdd))\n\n\treturn nil\n}\n\nfunc (a *activities) isRetryableError(err error) bool {\n\tvar esErr *elastic.Error\n\tif !errors.As(err, &esErr) {\n\t\treturn true\n\t}\n\n\tswitch esErr.Status {\n\tcase http.StatusBadRequest, http.StatusUnauthorized, http.StatusForbidden, http.StatusNotFound, http.StatusConflict:\n\t\treturn false","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/worker/addsearchattributes/workflow.go#L108-L144","documentation":"Error \"%w: %v\" thrown in temporalio/temporal.","triggerScenarios":"Thrown at service/worker/addsearchattributes/workflow.go:126 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}