{"record":{"id":"45f8056771b10476","repo":"temporalio/temporal","slug":"registrable-component-validation-error-search-att-45f805","errorCode":null,"errorMessage":"registrable component validation error: search attribute field %q is already defined","messagePattern":"registrable component validation error: search attribute field %q is already defined","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"chasm/registrable_component.go","lineNumber":153,"sourceCode":"\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\n// component's struct definition, such as configurations.\n//\n// Keys need to be globally unique across components. Conflicting keys across will cause component registration to fail.\n//","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/chasm/registrable_component.go#L135-L171","documentation":"This panic fires when two SearchAttribute entries on the same RegistrableComponent map to the same underlying field (the visibility column name), even if their aliases differ. fieldToAlias is also one-to-one, so two aliases pointing at one field would corrupt query mapping; registration panics to prevent the ambiguous field->alias mapping.","triggerScenarios":"Calling chasm.WithSearchAttributes with two SearchAttributes having distinct aliases but the same definition().field value (field already present in fieldToAlias).","commonSituations":"Declaring the same column with two alias spellings (e.g. 'OrderStatus' and 'order_status' both mapping to field 'OrderStatus'); merging attribute definitions from two components that share a field name; typos in field constants pointing at an existing column.","solutions":["Give each SearchAttribute a unique field name","Remove the redundant attribute definition and reuse the existing alias for the field","Verify field constants/definitions aren't accidentally shared between attribute declarations"],"exampleFix":"// before\nchasm.NewSearchAttribute(\"OrderStatus\", \"OrderStatus\", ...),\nchasm.NewSearchAttribute(\"Status\", \"OrderStatus\", ...) // same field\n// after\nchasm.NewSearchAttribute(\"OrderStatus\", \"OrderStatus\", ...) // one alias per field","handlingStrategy":"validation","validationCode":"seen := map[string]bool{}\nfor _, sa := range attrs {\n    if seen[sa.definition().field] {\n        return fmt.Errorf(\"duplicate field %q\", sa.definition().field)\n    }\n    seen[sa.definition().field] = true\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One alias per field; reuse an existing alias instead of adding a second","Define fields as constants shared across components that need them","Cover attribute registration in unit tests"],"tags":["chasm","search-attributes","registration","duplicate","panic"],"backgroundTag":"duplicate-search-attribute-field","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}