{"record":{"id":"7fc2bdba3a320665","repo":"temporalio/temporal","slug":"unknown-index-value-type-v","errorCode":null,"errorMessage":"unknown index value type %v","messagePattern":"unknown index value type (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/searchattribute/sadefs/util.go","lineNumber":30,"sourceCode":")\n\nfunc GetMetadataType(p *commonpb.Payload) enumspb.IndexedValueType {\n\tt, err := enumspb.IndexedValueTypeFromString(string(p.Metadata[MetadataType]))\n\tif err != nil {\n\t\treturn enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED\n\t}\n\treturn t\n}\n\nfunc SetMetadataType(p *commonpb.Payload, t enumspb.IndexedValueType) {\n\tif t == enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED {\n\t\treturn\n\t}\n\n\t_, isValidT := enumspb.IndexedValueType_name[int32(t)]\n\tif !isValidT {\n\t\t// nolint: forbidigo\n\t\tpanic(fmt.Sprintf(\"unknown index value type %v\", t))\n\t}\n\tp.Metadata[MetadataType] = []byte(t.String())\n}\n","sourceCodeStart":12,"sourceCodeEnd":34,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/searchattribute/sadefs/util.go#L12-L34","documentation":"SetMetadataType stamps the IndexedValueType into a Payload's search-attribute metadata. It panics when the passed type t is not a valid enumspb.IndexedValueType value (no name registered in the enum), because an unknown type cannot be serialized into metadata.","triggerScenarios":"Calling SetMetadataType (directly or via Encode/EncodeValue/ApplyTypeMap) with an out-of-range or undefined IndexedValueType — e.g. IndexedValueType(99) cast from an int, or a type from a newer proto not known to this binary.","commonSituations":"Converting custom/legacy type IDs to IndexedValueType via int casts; version skew with newer enum values; corrupt type maps passed to ApplyTypeMap.","solutions":["Pass only valid enumspb.IndexedValueType values (check enumspb.IndexedValueType_name)","Fix the type map / conversion code that produces the invalid type value","Upgrade the binary so the newer enum value is recognized"],"exampleFix":"// before\nt := enumspb.IndexedValueType(rawTypeID) // may be undefined\nsadefs.SetMetadataType(payload, t)\n// after\nif _, ok := enumspb.IndexedValueType_name[int32(rawTypeID)]; !ok {\n    return fmt.Errorf(\"unknown indexed value type %d\", rawTypeID)\n}\nsadefs.SetMetadataType(payload, enumspb.IndexedValueType(rawTypeID))","handlingStrategy":"validation","validationCode":"if _, ok := enumspb.IndexedValueType_name[int32(t)]; !ok {\n    return fmt.Errorf(\"unknown indexed value type %d\", int32(t))\n}\nsadefs.SetMetadataType(payload, t)","typeGuard":null,"tryCatchPattern":"func() (err error) {\n    defer func() {\n        if r := recover(); r != nil { err = fmt.Errorf(\"set metadata type: %v\", r) }\n    }()\n    sadefs.SetMetadataType(payload, t)\n    return nil\n}()","preventionTips":["Never cast raw ints to enumspb.IndexedValueType without validating against IndexedValueType_name","Synchronize proto enum versions across services","Validate type maps before ApplyTypeMap"],"tags":["go","panic","search-attributes","enum-validation"],"backgroundTag":"unknown-enum-policy","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}