{"record":{"id":"50c3012702a24941","repo":"googleapis/mcp-toolbox","slug":"error-getting-result-s","errorCode":null,"errorMessage":"error getting result: %s","messagePattern":"error getting result: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/redis/redis.go","lineNumber":193,"sourceCode":"\nfunc (s *Source) RunCommand(ctx context.Context, cmds [][]any) (any, error) {\n\t// Execute commands\n\tresponses := make([]*redis.Cmd, len(cmds))\n\tfor i, cmd := range cmds {\n\t\tresponses[i] = s.RedisClient().Do(ctx, cmd...)\n\t}\n\t// Parse responses\n\tout := make([]any, len(cmds))\n\tfor i, resp := range responses {\n\t\tif err := resp.Err(); err != nil {\n\t\t\t// Add error from each command to `errSum`\n\t\t\terrString := fmt.Sprintf(\"error from executing command at index %d: %s\", i, err)\n\t\t\tout[i] = errString\n\t\t\tcontinue\n\t\t}\n\t\tval, err := resp.Result()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error getting result: %s\", err)\n\t\t}\n\t\tout[i] = convertRedisResult(val)\n\t}\n\n\treturn out, nil\n}\n\n// convertRedisResult recursively converts redis results (map[any]any) to be\n// JSON-marshallable (map[string]any).\n// It converts map[any]any to map[string]any and handles nested structures.\nfunc convertRedisResult(v any) any {\n\tswitch val := v.(type) {\n\tcase map[any]any:\n\t\tm := make(map[string]any)\n\t\tfor k, v := range val {\n\t\t\tm[fmt.Sprint(k)] = convertRedisResult(v)\n\t\t}\n\t\treturn m","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/redis/redis.go#L175-L211","documentation":"RunCommand executes a sequence of Redis commands and converts each reply. After a successful cmd.Run, it calls resp.Result(); if the reply itself carries a Redis-level error value (e.g. the command executed but Redis returned an error result), this error aborts the whole invocation. Note the loop already handles per-command execution errors by writing an error string into the output, so this branch catches Result() extraction failures specifically.","triggerScenarios":"A command in the `commands` array succeeds at the go-redis Cmd.Run level but resp.Result() returns a non-nil err — typically a Redis server error surfaced as the reply value, such as WRONGTYPE, OOM, NOAUTH, or a command executed against a replica marked read-only.","commonSituations":"Calling a list command on a string key (WRONGTYPE); running write commands on a read-only replica; running out of memory (OOM command not allowed); authentication lost mid-session (NOAUTH); Lua/eval errors.","solutions":["Read the wrapped %s detail to identify the Redis error (WRONGTYPE, NOAUTH, OOM, READONLY).","Fix the command/key type mismatch: run `TYPE <key>` and use commands matching the value type.","If NOAUTH/WRONGPASS, correct the source's username/password configuration.","If READONLY, redirect writes to the primary or enable READWRITE on the target node.","If OOM, free memory or raise maxmemory on the Redis server."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check key types before issuing commands to avoid WRONGTYPE\n// redis-cli TYPE <key> should match the command family you intend to run","typeGuard":null,"tryCatchPattern":"try {\n  const out = await invokeTool('redis_run_command', { commands: [...] });\n} catch (e) {\n  if (String(e.message).includes('WRONGTYPE')) {\n    // inspect key type and reissue with a compatible command\n  } else if (String(e.message).includes('NOAUTH')) {\n    // fix source credentials and reconfigure\n  } else {\n    throw e;\n  }\n}","preventionTips":["Run `TYPE <key>` before operating on keys to avoid WRONGTYPE.","Never send write commands to replicas; target primaries.","Monitor server memory (maxmemory) to avoid OOM rejections.","Validate the commands array format (['GET','key'] arrays of strings) before invoking."],"tags":["redis","command-execution","go"],"backgroundTag":"redis-command-error","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}