{"record":{"id":"04b365c5189cec01","repo":"googleapis/mcp-toolbox","slug":"no-valid-commands-were-built-to-execute","errorCode":null,"errorMessage":"no valid commands were built to execute","messagePattern":"no valid commands were built to execute","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/valkey/valkey.go","lineNumber":142,"sourceCode":"\nfunc (s *Source) ToConfig() sources.SourceConfig {\n\treturn s.Config\n}\n\nfunc (s *Source) ValkeyClient() valkey.Client {\n\treturn s.Client\n}\n\nfunc (s *Source) RunCommand(ctx context.Context, cmds [][]string) (any, error) {\n\t// Build commands\n\tbuiltCmds := make(valkey.Commands, len(cmds))\n\n\tfor i, cmd := range cmds {\n\t\tbuiltCmds[i] = s.ValkeyClient().B().Arbitrary(cmd...).Build()\n\t}\n\n\tif len(builtCmds) == 0 {\n\t\treturn nil, fmt.Errorf(\"no valid commands were built to execute\")\n\t}\n\n\t// Execute commands\n\tresponses := s.ValkeyClient().DoMulti(ctx, builtCmds...)\n\n\t// Parse responses\n\tout := make([]any, len(cmds))\n\tfor i, resp := range responses {\n\t\tif err := resp.Error(); err != nil {\n\t\t\t// Store error message in the output for this command\n\t\t\tout[i] = fmt.Sprintf(\"error from executing command at index %d: %s\", i, err)\n\t\t\tcontinue\n\t\t}\n\t\tval, err := resp.ToAny()\n\t\tif err != nil {\n\t\t\tout[i] = fmt.Sprintf(\"error parsing response: %s\", err)\n\t\t\tcontinue\n\t\t}","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/valkey/valkey.go#L124-L160","documentation":"Valkey Source.RunCommand splits the requested commands, builds valkey-go arbitrary commands via B().Arbitrary(cmd...).Build(), and refuses to run when the resulting builtCmds slice is empty. Because builtCmds is allocated with len(cmds) entries, this fires only when zero commands were supplied in the first place — i.e. the tool invocation carried no command arguments.","triggerScenarios":"Calling RunCommand (via the valkey-run-command tool) with an empty commands list: the tool parameters array is missing, empty, or the invoking agent passed an empty array.","commonSituations":"An LLM agent invoking the run_command tool without filling the commands parameter; a client sending an empty JSON array for commands; misconfigured tool parameter defaults.","solutions":["Pass at least one command in the 'commands' parameter, e.g. [\"PING\"] or [\"GET\", \"mykey\"]","Ensure each command is provided as an array of argument strings (['SET','key','value']), not a single joined string","Validate client-side that the commands array is non-empty before invoking the tool"],"exampleFix":"// before (tool request)\n{\"commands\": []}\n// after\n{\"commands\": [[\"PING\"]]}","handlingStrategy":"validation","validationCode":"function validateCommands(cmds: unknown): asserts cmds is string[][] {\n  if (!Array.isArray(cmds) || cmds.length === 0)\n    throw new Error(\"'commands' must be a non-empty array of argument arrays\");\n  if (!cmds.every(c => Array.isArray(c) && c.every(a => typeof a === \"string\")))\n    throw new Error(\"each command must be an array of strings\");\n}","typeGuard":"function isNonEmptyCommandList(v: unknown): v is string[][] {\n  return Array.isArray(v) && v.length > 0 &&\n    v.every(c => Array.isArray(c) && c.length > 0 && c.every(a => typeof a === \"string\"));\n}","tryCatchPattern":"try {\n  const res = await runValkeyCommand(commands);\n} catch (err) {\n  if (String(err).includes(\"no valid commands were built\")) {\n    console.error(\"commands parameter was empty; send e.g. [[\\\"PING\\\"]]\");\n  }\n  throw err;\n}","preventionTips":["Always send at least one command; never pass an empty array","Constrain the tool schema in clients so 'commands' is required with minItems: 1","In agent prompts, show an example invocation with a concrete command"],"tags":["valkey","redis","validation","empty-input"],"backgroundTag":"empty-argument-list","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"}