{"record":{"id":"3f64734f25b3151e","repo":"sipeed/picoclaw","slug":"missing-value-for-s","errorCode":null,"errorMessage":"missing value for %s","messagePattern":"missing value for (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/mcp/add.go","lineNumber":112,"sourceCode":"\t\tswitch {\n\t\tcase arg == \"--help\" || arg == \"-h\":\n\t\t\treturn addOptions{}, \"\", \"\", nil, true, nil\n\t\tcase arg == \"--\":\n\t\t\tif i+1 < len(args) {\n\t\t\t\texplicitCommand = append(explicitCommand, args[i+1:]...)\n\t\t\t}\n\t\t\ti = len(args)\n\t\tcase arg == \"--force\" || arg == \"-f\":\n\t\t\topts.Force = true\n\t\tcase arg == \"--deferred\":\n\t\t\tt := true\n\t\t\topts.Deferred = &t\n\t\tcase arg == \"--no-deferred\":\n\t\t\tf := false\n\t\t\topts.Deferred = &f\n\t\tcase arg == \"--transport\" || arg == \"-t\":\n\t\t\tif i+1 >= len(args) {\n\t\t\t\treturn addOptions{}, \"\", \"\", nil, false, fmt.Errorf(\"missing value for %s\", arg)\n\t\t\t}\n\t\t\ti++\n\t\t\topts.Transport = args[i]\n\t\tcase strings.HasPrefix(arg, \"--transport=\"):\n\t\t\topts.Transport = strings.TrimPrefix(arg, \"--transport=\")\n\t\tcase arg == \"--env\" || arg == \"-e\":\n\t\t\tif i+1 >= len(args) {\n\t\t\t\treturn addOptions{}, \"\", \"\", nil, false, fmt.Errorf(\"missing value for %s\", arg)\n\t\t\t}\n\t\t\ti++\n\t\t\topts.Env = append(opts.Env, args[i])\n\t\tcase arg == \"--env-file\":\n\t\t\tif i+1 >= len(args) {\n\t\t\t\treturn addOptions{}, \"\", \"\", nil, false, fmt.Errorf(\"missing value for %s\", arg)\n\t\t\t}\n\t\t\ti++\n\t\t\topts.EnvFile = args[i]\n\t\tcase strings.HasPrefix(arg, \"--env=\"):","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/mcp/add.go#L94-L130","documentation":"`picoclaw mcp add` parses its arguments manually (not via cobra) so that everything after the server command can be forwarded to it. When --transport/-t appears as the final token with nothing following, the parser has no value to consume and returns this error before any config work starts.","triggerScenarios":"`picoclaw mcp add name url --transport` or `... -t` as the last argument; also when a script passes an empty unquoted variable so the value token disappears.","commonSituations":"Truncated shell line; quoting mistake; conditional flag assembly in scripts with an unset variable.","solutions":["Supply the value: `--transport http` or use the explicit form `--transport=http`","Quote script expansions so the token survives: `--transport \"$TRANSPORT\"`","Guard scripts: skip the flag when the variable is empty"],"exampleFix":"# before\npicoclaw mcp add myapi https://example.com/mcp --transport\n# after\npicoclaw mcp add myapi https://example.com/mcp --transport=http","handlingStrategy":"validation","validationCode":"# prefer = forms so a missing value is a shell syntax error, not a runtime one\npicoclaw mcp add name url --transport=http","typeGuard":"func hasFlagValue(args []string, names ...string) bool {\n    for i, a := range args {\n        for _, n := range names {\n            if a == n {\n                return i+1 < len(args)\n            }\n        }\n    }\n    return true\n}","tryCatchPattern":null,"preventionTips":["Use --flag=value instead of --flag value in generated commands","Quote variable expansions so tokens never disappear","Assemble long mcp add commands in an array, not string interpolation"],"tags":["mcp","cli","usage","flags"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}