{"record":{"id":"8b4d91a1658a56b4","repo":"temporalio/temporal","slug":"w-invalid-item-value-type-in-keywordlist-value","errorCode":null,"errorMessage":"%w: invalid item value type in KeywordList value (got: %T, expected: string)","messagePattern":"%w: invalid item value type in KeywordList value \\(got: %T, expected: string\\)","errorType":"exception","errorClass":"converter.ErrUnableToDecode","httpStatus":null,"severity":"error","filePath":"common/searchattribute/sadefs/encode_value.go","lineNumber":160,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif dv == nil {\n\t\treturn nil, nil\n\t}\n\t// Validate that every value is a string.\n\ttdv, ok := dv.([]any)\n\tif !ok {\n\t\t//nolint:forbidigo // this should never happen\n\t\tpanic(fmt.Sprintf(\"unexpected return type of decodeValueTyped (got: %T, expected: []any)\", dv))\n\t}\n\tres := make([]string, len(tdv))\n\tfor i, v := range tdv {\n\t\tswitch vt := v.(type) {\n\t\tcase string:\n\t\t\tres[i] = vt\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"%w: invalid item value type in KeywordList value (got: %T, expected: string)\",\n\t\t\t\tconverter.ErrUnableToDecode,\n\t\t\t\tdv,\n\t\t\t)\n\t\t}\n\t}\n\treturn res, nil\n}\n","sourceCodeStart":142,"sourceCodeEnd":169,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/searchattribute/sadefs/encode_value.go#L142-L169","documentation":"DecodeKeywordList wraps converter.ErrUnableToDecode when an element of the decoded value is not a Go string. After the payload converter produces []any, each item must be a string for a KEYWORD_LIST; any other item type (number, bool, nested list) aborts with the offending value's dynamic type reported. Note the message prints the whole dv value's type, not the item's, which can be slightly misleading.","triggerScenarios":"Calling DecodeKeywordList (or Validate) on a payload whose list contains non-string items — e.g. a mixed-type list encoded via a generic JSON converter or hand-built temporal/api common Payload.","commonSituations":"Values built by external tools writing raw payloads; data migrated from another system where the field held heterogeneous types; SDK versions encoding nil/non-string items.","solutions":["Ensure the encoder writes only string items into KeywordList values (use sadefs.EncodeValue with []string).","Coerce/convert numeric or bool items to strings at the producer before encoding.","Inspect the payload items (the offending value is named in the error) and fix the writer."],"exampleFix":"// before\nitems := []any{\"a\", 42}\npayload, _ := converter.DefaultDataConverter.ToPayload(items)\n// after\npayload, _ := sadefs.EncodeValue([]string{\"a\", \"42\"}, false)","handlingStrategy":"type-guard","validationCode":"for _, v := range items {\n    if _, ok := v.(string); !ok {\n        return fmt.Errorf(\"keyword list contains non-string item\")\n    }\n}","typeGuard":"func isStringList(items []any) bool {\n    for _, v := range items {\n        if _, ok := v.(string); !ok {\n            return false\n        }\n    }\n    return true\n}","tryCatchPattern":"if errors.Is(err, converter.ErrUnableToDecode) { /* inspect payload items and fix producer */ }","preventionTips":["Encode keyword lists only from []string via sadefs.EncodeValue","Reject heterogeneous lists at the producer","Avoid hand-building payloads with generic converters for KEYWORD_LIST"],"tags":["go","search-attributes","keyword-list","type-mismatch"],"backgroundTag":"unable-to-decode-payload","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}