{"record":{"id":"5aec194fc705c8ac","repo":"temporalio/temporal","slug":"invalid-searchattributes-on-continueasnewworkflowe","errorCode":null,"errorMessage":"invalid SearchAttributes on ContinueAsNewWorkflowExecutionCommand: %w. WorkflowType=%s TaskQueue=%s","messagePattern":"invalid SearchAttributes on ContinueAsNewWorkflowExecutionCommand: %w\\. WorkflowType=(.+?) TaskQueue=(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/history/api/command_attr_validator.go","lineNumber":452,"sourceCode":"\n\tif attributes.GetWorkflowRunTimeout().AsDuration() == 0 {\n\t\tattributes.WorkflowRunTimeout = executionInfo.WorkflowRunTimeout\n\t}\n\n\tif attributes.GetWorkflowTaskTimeout().AsDuration() == 0 {\n\t\tattributes.WorkflowTaskTimeout = executionInfo.DefaultWorkflowTaskTimeout\n\t}\n\n\tattributes.WorkflowRunTimeout = durationpb.New(overrideWorkflowRunTimeout(attributes.GetWorkflowRunTimeout().AsDuration(), executionInfo.GetWorkflowExecutionTimeout().AsDuration()))\n\n\tattributes.WorkflowTaskTimeout = durationpb.New(overrideWorkflowTaskTimeout(namespaceName, attributes.GetWorkflowTaskTimeout().AsDuration(), attributes.GetWorkflowRunTimeout().AsDuration(), v.config.DefaultWorkflowTaskTimeout))\n\n\tif err := v.validateWorkflowRetryPolicy(namespaceName, attributes.RetryPolicy); err != nil {\n\t\treturn failedCause, fmt.Errorf(\"invalid WorkflowRetryPolicy on ContinueAsNewWorkflowExecutionCommand: %w. WorkflowType=%s TaskQueue=%s\", err, wfType, attributes.TaskQueue)\n\t}\n\n\tif err := v.searchAttributesValidator.Validate(attributes.GetSearchAttributes(), namespaceName.String()); err != nil {\n\t\treturn enumspb.WORKFLOW_TASK_FAILED_CAUSE_BAD_SEARCH_ATTRIBUTES, fmt.Errorf(\"invalid SearchAttributes on ContinueAsNewWorkflowExecutionCommand: %w. WorkflowType=%s TaskQueue=%s\", err, wfType, attributes.TaskQueue)\n\t}\n\n\treturn enumspb.WORKFLOW_TASK_FAILED_CAUSE_UNSPECIFIED, nil\n}\n\nfunc (v *CommandAttrValidator) ValidateStartChildExecutionAttributes(\n\tnamespaceID namespace.ID,\n\ttargetNamespaceID namespace.ID,\n\ttargetNamespace namespace.Name,\n\tattributes *commandpb.StartChildWorkflowExecutionCommandAttributes,\n\tparentInfo *persistencespb.WorkflowExecutionInfo,\n\tdefaultWorkflowTaskTimeoutFn dynamicconfig.DurationPropertyFnWithNamespaceFilter,\n) (enumspb.WorkflowTaskFailedCause, error) {\n\n\tconst failedCause = enumspb.WORKFLOW_TASK_FAILED_CAUSE_BAD_START_CHILD_EXECUTION_ATTRIBUTES\n\n\tif attributes == nil {\n\t\treturn failedCause, serviceerror.NewInvalidArgument(\"StartChildWorkflowExecutionCommandAttributes is not set on StartChildWorkflowExecutionCommand.\")","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/history/api/command_attr_validator.go#L434-L470","documentation":"The ContinueAsNew command's SearchAttributes fail the searchAttributesValidator (invalid key names, unsupported value types, exceeding limits, or bad encoding). Fails the workflow task with WORKFLOW_TASK_FAILED_CAUSE_BAD_SEARCH_ATTRIBUTES.","triggerScenarios":"ContinueAsNew passing SearchAttributes option with keys that aren't valid identifiers, values not matching indexed field types, or using the deprecated search-attribute path incorrectly.","commonSituations":"Old code using SearchAttributes after server migrated to TypedSearchAttributes; unregistered custom keys; special characters in keys; visibility schema version mismatch.","solutions":["Migrate to TypedSearchAttributes with SearchAttributeKey types","Register custom search attributes in the namespace before use","Use only alphanumeric/underscore keys within length limits","Verify value types match the registered attribute type"],"exampleFix":"// before\nworkflow.NewContinueAsNewError(ctx, fn, opts.SearchAttributes(rawMap))\n// after\nworkflow.NewContinueAsNewError(ctx, fn, opts.TypedSearchAttributes(search.NewValidatedAttributes(key, val)))","handlingStrategy":"validation","validationCode":"for k := range attrs { if !search.IsValidKey(k) { return fmt.Errorf(\"invalid search attribute key %s\", k) } }","typeGuard":"func isTypedSearchAttributes(v interface{}) (temporal.SearchAttributes, bool) { tsa, ok := v.(temporal.SearchAttributes); return tsa, ok }","tryCatchPattern":"workflow-level recovery: on failure inspect WORKFLOW_TASK_FAILED_CAUSE_BAD_SEARCH_ATTRIBUTES in history and correct attributes before retrying ContinueAsNew","preventionTips":["Use TypedSearchAttributes exclusively","Register keys in the namespace first","Match value types to registered types"],"tags":["searchattributes","workflow","continueasnew","validation","history"],"backgroundTag":"invalid-search-attributes","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}