{"record":{"id":"4e067a4c48ff7bab","repo":"t8y2/dbx","slug":"unsupported-value-encoding-s","errorCode":null,"errorMessage":"Unsupported value encoding: %s","messagePattern":"Unsupported value encoding: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/etcd-go/kv.go","lineNumber":546,"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 longString(value int64) string {\n\treturn strconv.FormatInt(value, 10)\n}\n\nfunc unsignedLongString(value int64) string {\n\treturn strconv.FormatUint(uint64(value), 10)\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","sourceCodeStart":528,"sourceCodeEnd":564,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/etcd-go/kv.go#L528-L564","documentation":"parseValueObject decodes etcd values returned by kv operations into human-readable form based on a requested encoding. Only 'base64' (and 'utf8' passthrough) are supported; any other encoding string is rejected with this error. It is a strict input-validation error on the encoding parameter, not a data-corruption error.","triggerScenarios":"Calling put, keyBytesParam, or any op that flows through parseValueObject with an encoding value other than \"base64\" or \"utf8\" (e.g. \"hex\", \"UTF-8\", \"ascii\", \"string\").","commonSituations":"Hand-written JSON requests to the kv driver using an intuitive-but-unsupported encoding name like \"text\" or \"string\"; case mismatch (\"UTF8\" vs \"utf8\"); client SDK versions where encoding param naming changed; copying examples from a different driver that supports hex.","solutions":["Change the encoding parameter to exactly \"utf8\" (lowercase) for plain text values.","Use \"base64\" and base64-encode binary values before sending.","Normalize casing/whitespace on the caller side: strings.ToLower(strings.TrimSpace(encoding)) before sending.","Consult the driver's supported encoding list in kv.go parseValueObject and stick to it; do not invent values like \"hex\"."],"exampleFix":"// before\n{\"key\": \"Zm9v\", \"value\": \"YmFy\", \"encoding\": \"UTF8\"}\n// after\n{\"key\": \"Zm9v\", \"value\": \"YmFy\", \"encoding\": \"utf8\"}","handlingStrategy":"validation","validationCode":"func validEncoding(enc string) bool {\n\tswitch strings.ToLower(enc) {\n\tcase \"utf8\", \"base64\":\n\t\treturn true\n\t}\n\treturn false\n}\n// if !validEncoding(enc) { return error before calling the driver }","typeGuard":"func isSupportedEncoding(v any) bool {\n\ts, ok := v.(string)\n\tif !ok {\n\t\treturn false\n\t}\n\treturn s == \"utf8\" || s == \"base64\"\n}","tryCatchPattern":"value, err := driverPut(req)\nif err != nil {\n\tif strings.HasPrefix(err.Error(), \"Unsupported value encoding\") {\n\t\t// fall back to base64 and re-encode the payload\n\t\treq.Encoding = \"base64\"\n\t\treq.Value = base64.StdEncoding.EncodeToString(raw)\n\t\tvalue, err = driverPut(req)\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"put failed: %w\", err)\n\t}\n}","preventionTips":["Restrict the encoding input to a validated allowlist in your client API.","Normalize encoding strings (lowercase, trim) before sending.","Default to \"base64\" for binary payloads and \"utf8\" for text; never free-form values.","Document supported encodings where the request schema is defined."],"tags":["encoding","validation","etcd","kv"],"backgroundTag":"unsupported-encoding","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"}