{"record":{"id":"aaf795b75d36cecb","repo":"temporalio/temporal","slug":"w-v-aaf795","errorCode":null,"errorMessage":"%w: %v","messagePattern":"%w: %v","errorType":"exception","errorClass":"sadefs.ErrInvalidType","httpStatus":null,"severity":"error","filePath":"common/searchattribute/stringify.go","lineNumber":146,"sourceCode":"\tvar err error\n\n\tswitch t {\n\tcase enumspb.INDEXED_VALUE_TYPE_TEXT,\n\t\tenumspb.INDEXED_VALUE_TYPE_KEYWORD,\n\t\tenumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST:\n\t\tval = valStr\n\tcase enumspb.INDEXED_VALUE_TYPE_INT:\n\t\tval, err = strconv.ParseInt(valStr, 10, 64)\n\tcase enumspb.INDEXED_VALUE_TYPE_DOUBLE:\n\t\tval, err = strconv.ParseFloat(valStr, 64)\n\tcase enumspb.INDEXED_VALUE_TYPE_BOOL:\n\t\tval, err = strconv.ParseBool(valStr)\n\tcase enumspb.INDEXED_VALUE_TYPE_DATETIME:\n\t\tval, err = time.Parse(time.RFC3339Nano, valStr)\n\tcase enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED:\n\t\tval = parseValueUnspecified(valStr)\n\tdefault:\n\t\terr = fmt.Errorf(\"%w: %v\", sadefs.ErrInvalidType, t)\n\t}\n\n\treturn val, err\n}\n\nfunc parseValueUnspecified(valStr string) any {\n\tvar val any\n\tvar err error\n\n\tif val, err = strconv.ParseInt(valStr, 10, 64); err == nil {\n\t} else if val, err = strconv.ParseBool(valStr); err == nil {\n\t} else if val, err = strconv.ParseFloat(valStr, 64); err == nil {\n\t} else if val, err = time.Parse(time.RFC3339Nano, valStr); err == nil {\n\t} else if isJSONArray(valStr) {\n\t\tarr, err := parseJSONArray(valStr, enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED)\n\t\tif err != nil {\n\t\t\tval = valStr\n\t\t} else {","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/searchattribute/stringify.go#L128-L164","documentation":"parseValueTyped converts a plain string (from Stringify/Parse of a search attribute) back into a typed value. Its switch handles Bool, Datetime, and UNSPECIFIED; any other declared type (Keyword, Text, KeywordList, Int, etc.) hits the default branch and returns sadefs.ErrInvalidType, because those types are not parseable from a bare string by this single-value parser.","triggerScenarios":"Calling Stringify/Parse (via parseValueOrArray -> parseValueTyped) on a search attribute whose declared type is not Bool/Datetime — e.g. parsing \"MyKeyword=abc\" where the type maps to KEYWORD through the scalar path instead of the array/string path.","commonSituations":"Using searchattribute.Parse on user-supplied key=value strings where the attribute type resolution yields an unparseable type; feeding KeywordList-typed attributes into the scalar parser instead of parseJSONArray.","solutions":["Only run parseValueTyped for Bool/Datetime/Unspecified types; use the appropriate string/JSON path for Keyword/Text.","Route list types (KeywordList) through parseValueOrArray so parseJSONArray handles them.","Verify the type map returns the expected type for the attribute name before parsing."],"exampleFix":"// before\nval, err := parseValueTyped(enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST, \"[\\\"a\\\"]\") // invalid\n// after\nval, err := parseJSONArray(enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST, \"[\\\"a\\\"]\")","handlingStrategy":"type-guard","validationCode":"switch t {\ncase enumspb.INDEXED_VALUE_TYPE_BOOL, enumspb.INDEXED_VALUE_TYPE_DATETIME,\n    enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED:\ndefault:\n    return fmt.Errorf(\"type %v not parseable as scalar\", t)\n}","typeGuard":"func scalarParseable(t enumspb.IndexedValueType) bool {\n    return t == enumspb.INDEXED_VALUE_TYPE_BOOL ||\n        t == enumspb.INDEXED_VALUE_TYPE_DATETIME ||\n        t == enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED\n}","tryCatchPattern":"if errors.Is(err, sadefs.ErrInvalidType) { /* route to parseJSONArray or string path */ }","preventionTips":["Resolve the attribute type first and choose the matching parse path","Send Keyword/Text values through string handling, not parseValueTyped","Test Parse/Stringify round-trips for each attribute type"],"tags":["go","search-attributes","parse","invalid-type"],"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"}