{"record":{"id":"b64fe1dd01b990f4","repo":"t8y2/dbx","slug":"unsupported-value-encoding-s-b64fe1","errorCode":null,"errorMessage":"Unsupported value encoding: %s","messagePattern":"Unsupported value encoding: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/etcd2-go/kv.go","lineNumber":457,"sourceCode":"\t}\n\treturn base64.StdEncoding.EncodeToString(bytes)\n}\n\nfunc parseValueObject(value map[string]json.RawMessage) (string, error) {\n\tif value == nil {\n\t\tvalue = map[string]json.RawMessage{}\n\t}\n\tencoding := stringOrDefault(value, \"encoding\", \"utf8\")\n\tdata := stringOrDefault(value, \"data\", \"\")\n\tif encoding == \"base64\" {\n\t\tdecoded, err := base64.StdEncoding.DecodeString(data)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn string(decoded), nil\n\t}\n\tif encoding != \"utf8\" {\n\t\treturn \"\", fmt.Errorf(\"Unsupported value encoding: %s\", encoding)\n\t}\n\treturn data, nil\n}\n\nfunc stringOrNull(params map[string]json.RawMessage, key string) *string {\n\traw := params[key]\n\tif len(raw) == 0 || string(raw) == \"null\" {\n\t\treturn nil\n\t}\n\tvar value string\n\tif err := json.Unmarshal(raw, &value); err != nil {\n\t\treturn nil\n\t}\n\treturn &value\n}\n\nfunc stringOrDefault(params map[string]json.RawMessage, key string, fallback string) string {\n\tvalue := stringOrNull(params, key)","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/etcd2-go/kv.go#L439-L475","documentation":"parseValueObject rejects a value-encoding parameter that is not one of the supported encodings (base64/decoded variants and 'utf8'). The v2 driver only knows how to decode a fixed set of encodings, so any other string is refused before touching the server. Raised from put and keyBytesParam.","triggerScenarios":"Calling put (or a key-setting method that passes keyBytesParam) with an 'encoding' field whose value is e.g. 'base85', 'UTF-8' (capitalized), 'binary', or any misspelling other than the accepted set ending in 'utf8'.","commonSituations":"Typo or case mismatch ('UTF-8' vs 'utf8'), assuming other base64 variants are supported, copying an encoding name from a different library's API.","solutions":["Use one of the supported encoding strings; plain text must be 'utf8' (exact lowercase).","Pre-encode binary data yourself as base64 and use the base64 encoding option instead.","Check the accepted values in parseValueObject in agents/drivers/etcd2-go/kv.go before sending."],"exampleFix":"// before\nput({\"key\": \"a2V5\", \"value\": \"dmFsdWU=\", \"encoding\": \"base85\"})\n// after\nput({\"key\": \"a2V5\", \"value\": \"dmFsdWU=\", \"encoding\": \"base64\"})","handlingStrategy":"validation","validationCode":"var allowed = map[string]bool{\"utf8\": true, \"base64\": true}\nif encoding != \"\" && !allowed[strings.ToLower(encoding)] { return fmt.Errorf(\"unsupported encoding %q; use utf8 or base64\", encoding) }","typeGuard":"func validEncoding(e string) bool { switch e { case \"utf8\", \"base64\": return true }; return false }","tryCatchPattern":"if err := put(params); err != nil && strings.Contains(err.Error(), \"Unsupported value encoding\") {\n    return fmt.Errorf(\"fix encoding param to utf8 or base64: %w\", err)\n}","preventionTips":["Always send encoding as exact lowercase 'utf8' for plain text","Base64-encode binary payloads yourself before put","Keep a shared constants list of accepted encodings"],"tags":["etcd","validation","encoding"],"backgroundTag":"invalid-enum-value","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}