{"record":{"id":"6070ea88e9e5638b","repo":"temporalio/temporal","slug":"w-v","errorCode":null,"errorMessage":"%w: %v","messagePattern":"%w: %v","errorType":"exception","errorClass":"sadefs.ErrInvalidType","httpStatus":null,"severity":"error","filePath":"common/searchattribute/sadefs/encode_value.go","lineNumber":49,"sourceCode":"\t\tpanic(err)\n\t}\n\treturn valPayload\n}\n\n// DecodeValue decodes search attribute value from Payload using (in order):\n// 1. passed type t.\n// 2. type from MetadataType field, if t is not specified.\n// allowList allows list of values when it's not keyword list type.\nfunc DecodeValue(\n\tvalue *commonpb.Payload,\n\tt enumspb.IndexedValueType,\n\tallowList bool,\n) (any, error) {\n\tif t == enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED {\n\t\tt = GetMetadataType(value)\n\t}\n\tif t == enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED {\n\t\treturn nil, fmt.Errorf(\"%w: %v\", ErrInvalidType, t)\n\t}\n\n\tswitch t {\n\tcase enumspb.INDEXED_VALUE_TYPE_BOOL:\n\t\treturn decodeValueTyped[bool](value, allowList)\n\tcase enumspb.INDEXED_VALUE_TYPE_DATETIME:\n\t\treturn decodeValueTyped[time.Time](value, allowList)\n\tcase enumspb.INDEXED_VALUE_TYPE_DOUBLE:\n\t\treturn decodeValueTyped[float64](value, allowList)\n\tcase enumspb.INDEXED_VALUE_TYPE_INT:\n\t\treturn decodeValueTyped[int64](value, allowList)\n\tcase enumspb.INDEXED_VALUE_TYPE_KEYWORD:\n\t\treturn validateStrings(decodeValueTyped[string](value, allowList))\n\tcase enumspb.INDEXED_VALUE_TYPE_TEXT:\n\t\treturn validateStrings(decodeValueTyped[string](value, allowList))\n\tcase enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST:\n\t\treturn validateStrings(decodeValueTyped[[]string](value, false))\n\tdefault:","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/searchattribute/sadefs/encode_value.go#L31-L67","documentation":"DecodeValue wraps sadefs.ErrInvalidType when the effective INDEXED_VALUE_TYPE is UNSPECIFIED. It first tries GetMetadataType(value) to infer the type from payload metadata; if that also yields UNSPECIFIED, there is no way to know how to decode the payload, so it fails. This guards against decoding visibility-store payloads that carry no type metadata.","triggerScenarios":"Calling DecodeValue with an INDEXED_VALUE_TYPE_UNSPECIFIED type on a payload whose metadata also lacks a search-attribute type key — e.g. a payload written without EncodeValue or with metadata stripped.","commonSituations":"Custom visibility store integrations that construct payloads manually; payloads produced by an older SDK version that did not stamp type metadata; copying payloads between stores losing metadata fields.","solutions":["Encode values with sadefs.EncodeValue so type metadata is attached to the payload.","Pass an explicit non-UNSPECIFIED enumspb.IndexedValueType to DecodeValue instead of relying on metadata inference.","Verify the payload metadata retains the search-attribute type key through any intermediate storage or copying."],"exampleFix":"// before\nval, err := sadefs.DecodeValue(payload, enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED, false) // metadata missing\n// after\nval, err := sadefs.DecodeValue(payload, enumspb.INDEXED_VALUE_TYPE_KEYWORD, false)","handlingStrategy":"validation","validationCode":"if t == enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED && sadefs.GetMetadataType(payload) == enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED {\n    return fmt.Errorf(\"payload has no search attribute type metadata\")\n}","typeGuard":null,"tryCatchPattern":"if errors.Is(err, sadefs.ErrInvalidType) { /* re-encode or request explicit type from caller */ }","preventionTips":["Always encode with sadefs.EncodeValue so metadata is stamped","Avoid copying payloads through paths that drop metadata keys","Pass explicit types when metadata is untrustworthy"],"tags":["go","search-attributes","invalid-type","payload-metadata"],"backgroundTag":"invalid-search-attribute-type","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}