{"record":{"id":"6f261140e8c6b849","repo":"temporalio/temporal","slug":"registrable-component-validation-error-search-att","errorCode":null,"errorMessage":"registrable component validation error: search attribute alias %q is already defined","messagePattern":"registrable component validation error: search attribute alias %q is already defined","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"chasm/registrable_component.go","lineNumber":149,"sourceCode":"\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif sadefs.IsChasmSystem(alias) {\n\t\t\t\t//nolint:forbidigo\n\t\t\t\tpanic(fmt.Sprintf(\"registrable component validation error: CHASM search attribute alias %q is a CHASM system search attribute\", alias))\n\t\t\t}\n\t\t\tif !sadefs.IsSystem(alias) && sadefs.IsReserved(alias) {\n\t\t\t\t//nolint:forbidigo\n\t\t\t\tpanic(fmt.Sprintf(\"registrable component validation error: CHASM search attribute alias %q is a reserved search attribute\", alias))\n\t\t\t}\n\n\t\t\tif _, ok := rc.searchAttributesMapper.systemAliasToField[alias]; ok {\n\t\t\t\t//nolint:forbidigo\n\t\t\t\tpanic(fmt.Sprintf(\"registrable component validation error: CHASM search attribute alias %q is already defined as a system search attribute alias\", alias))\n\t\t\t}\n\t\t\tif _, ok := rc.searchAttributesMapper.aliasToField[alias]; ok {\n\t\t\t\t//nolint:forbidigo\n\t\t\t\tpanic(fmt.Sprintf(\"registrable component validation error: search attribute alias %q is already defined\", alias))\n\t\t\t}\n\t\t\tif _, ok := rc.searchAttributesMapper.fieldToAlias[field]; ok {\n\t\t\t\t//nolint:forbidigo\n\t\t\t\tpanic(fmt.Sprintf(\"registrable component validation error: search attribute field %q is already defined\", field))\n\t\t\t}\n\n\t\t\trc.searchAttributesMapper.aliasToField[alias] = field\n\t\t\trc.searchAttributesMapper.fieldToAlias[field] = alias\n\t\t\trc.searchAttributesMapper.saTypeMap[field] = valueType\n\t\t}\n\t}\n}\n\n// WithContextValues allows specifying key-value pairs that will be available in the Context\n// via the Value() method whenever the chasm framework starts, updates, reads, polls, executes or\n// validates tasks on a component.\n//\n// This is useful for propagating values needed for those processing logic but are not avaiable via the","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/chasm/registrable_component.go#L131-L167","documentation":"This panic occurs when two SearchAttribute entries passed to WithSearchAttributes on the same RegistrableComponent use the same alias. The mapper stores aliasToField one-to-one, so a duplicate alias would silently overwrite the earlier mapping; registration instead panics to surface the conflict at startup.","triggerScenarios":"Calling chasm.WithSearchAttributes(sa1, sa2, ...) where sa1.definition().alias == sa2.definition().alias, or calling WithSearchAttributes twice on the same component with a repeated alias (alias already present in aliasToField).","commonSituations":"Copy-pasting a SearchAttribute list where an attribute was declared twice; two team members adding attributes with the same short name (e.g. 'Status'); refactoring that merged two attribute lists without deduplicating.","solutions":["Deduplicate the SearchAttribute list before passing it to WithSearchAttributes","Rename one of the colliding aliases to a unique name","Centralize the component's search attribute definitions in one place so duplicates are obvious"],"exampleFix":"// before\nchasm.WithSearchAttributes(saStatus, saOrderStatus) // both alias \"Status\"\n// after\nchasm.WithSearchAttributes(saStatus) // single definition per alias","handlingStrategy":"validation","validationCode":"seen := map[string]bool{}\nfor _, sa := range attrs {\n    if seen[sa.definition().alias] {\n        return fmt.Errorf(\"duplicate alias %q\", sa.definition().alias)\n    }\n    seen[sa.definition().alias] = true\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Deduplicate attribute lists centrally before registration","Use named constants for aliases instead of string literals","Add a unit test asserting each component's attribute list has unique aliases"],"tags":["chasm","search-attributes","registration","duplicate","panic"],"backgroundTag":"duplicate-search-attribute-alias","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}