{"record":{"id":"442c429cb87cc8d2","repo":"redis/go-redis","slug":"redis-json-set-mode-must-be-nx-or-xx","errorCode":null,"errorMessage":"redis: JSON.SET mode must be NX or XX","messagePattern":"redis: JSON\\.SET mode must be NX or XX","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"json.go","lineNumber":648,"sourceCode":"func (c cmdable) JSONSetWithArgs(ctx context.Context, key, path string, value interface{}, options *JSONSetArgsOptions) *StatusCmd {\n\tvar bytes []byte\n\tvar err error\n\tswitch v := value.(type) {\n\tcase string:\n\t\tbytes = []byte(v)\n\tcase []byte:\n\t\tbytes = v\n\tdefault:\n\t\tbytes, err = json.Marshal(v)\n\t}\n\targs := []interface{}{\"JSON.SET\", key, path, util.BytesToString(bytes)}\n\tif options != nil {\n\t\tif options.Mode != \"\" {\n\t\t\tswitch strings.ToUpper(options.Mode) {\n\t\t\tcase \"XX\", \"NX\":\n\t\t\t\targs = append(args, strings.ToUpper(options.Mode))\n\t\t\tdefault:\n\t\t\t\tpanic(\"redis: JSON.SET mode must be NX or XX\")\n\t\t\t}\n\t\t}\n\t\tif options.FPHA != \"\" {\n\t\t\targs = append(args, \"FPHA\", string(options.FPHA))\n\t\t}\n\t}\n\tcmd := NewStatusCmd(ctx, args...)\n\tif err != nil {\n\t\tcmd.SetErr(err)\n\t} else {\n\t\t_ = c(ctx, cmd)\n\t}\n\treturn cmd\n}\n\n// JSONStrAppend appends the JSON-string values to the string at the specified path.\n// For more information, see https://redis.io/commands/json.strappend\nfunc (c cmdable) JSONStrAppend(ctx context.Context, key, path, value string) *IntPointerSliceCmd {","sourceCodeStart":630,"sourceCodeEnd":666,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/json.go#L630-L666","documentation":"Error \"redis: JSON.SET mode must be NX or XX\" thrown in redis/go-redis.","triggerScenarios":"Thrown at json.go:648 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}