{"record":{"id":"9a5c3611d4030bae","repo":"cilium/cilium","slug":"could-not-transcode-q-value-w","errorCode":null,"errorMessage":"could not transcode %q value: %w","messagePattern":"could not transcode %q value: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/kvstore/commands.go","lineNumber":57,"sourceCode":"\t\t\tArgs:    \"key value-file\",\n\t\t},\n\t\tfunc(s *script.State, args ...string) (script.WaitFunc, error) {\n\t\t\tif len(args) != 2 {\n\t\t\t\treturn nil, fmt.Errorf(\"%w: expected key and value file\", script.ErrUsage)\n\t\t\t}\n\t\t\tkey := args[0]\n\t\t\tvalue, err := os.ReadFile(s.Path(args[1]))\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"could not read %q: %w\", s.Path(args[1]), err)\n\t\t\t}\n\n\t\t\t// As this is a dev/test only command, we can be a bit more\n\t\t\t// aggressive with trimming whitespace to simplify our test scripts.\n\t\t\tvalue = bytes.TrimSpace(value)\n\n\t\t\tvalue, err = tryTranscodeFromJSON(key, value)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"could not transcode %q value: %w\", key, err)\n\t\t\t}\n\n\t\t\treturn nil, c.client.Update(s.Context(), key, value, false)\n\t\t},\n\t)\n}\n\nfunc (c cmds) delete() script.Cmd {\n\treturn script.Command(\n\t\tscript.CmdUsage{\n\t\t\tSummary: \"delete kvstore key-value\",\n\t\t\tArgs:    \"key\",\n\t\t},\n\t\tfunc(s *script.State, args ...string) (script.WaitFunc, error) {\n\t\t\tif len(args) != 1 {\n\t\t\t\treturn nil, fmt.Errorf(\"%w: expected key\", script.ErrUsage)\n\t\t\t}\n\t\t\treturn nil, c.client.Delete(s.Context(), args[0])","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/kvstore/commands.go#L39-L75","documentation":"Before writing, the kvstore 'set' command runs tryTranscodeFromJSON on the trimmed file content; if transcoding fails (e.g. the key has a registered schema/type and the file content is not valid or compatible JSON) it wraps the error as 'could not transcode %q value: %w'.","triggerScenarios":"tryTranscodeFromJSON(key, value) returns an error — the value file content is not valid JSON when the key requires JSON decoding, or doesn't match the expected shape for that key.","commonSituations":"Malformed JSON in the value file (trailing commas, unquoted strings); whitespace/newlines breaking parsing for keys expecting strict JSON; writing a JSON value to a key registered for a different type.","solutions":["Validate the value file contains well-formed JSON (jq . value.txt)","Trim stray whitespace/newlines (the command already trims spaces but content must still be valid JSON)","Check whether the key has a registered transcoding and what type it expects"],"exampleFix":"// before\n// value.txt: {\"a\": 1,}\n// after\n// value.txt: {\"a\": 1}","handlingStrategy":"validation","validationCode":"if _, err := json.Valid(value); !err {\n    return fmt.Errorf(\"value for %q is not valid JSON\", key)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate JSON in value files with jq before use","Know which key prefixes are JSON-transcoded","Avoid stray characters; keep value files minimal and trimmed"],"tags":["json","kvstore","transcode","script"],"backgroundTag":"json-parse-error","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}