{"record":{"id":"ad32af27ec7b8635","repo":"multica-ai/multica","slug":"s-stdin-empty-input-s","errorCode":null,"errorMessage":"--%s-stdin: empty input%s","messagePattern":"--(.+?)-stdin: empty input(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_agent.go","lineNumber":1407,"sourceCode":"\t\treturn nil, false, fmt.Errorf(\"--%s, --%s-stdin, and --%s-file are mutually exclusive; pick one\", prefix, prefix, prefix)\n\t}\n\n\tclearHint := \"\"\n\tif allowNull {\n\t\tclearHint = \"; pass 'null' to clear\"\n\t}\n\tvar raw string\n\tswitch {\n\tcase inline:\n\t\traw, _ = cmd.Flags().GetString(prefix)\n\tcase fromStdin:\n\t\tbuf, err := io.ReadAll(cmd.InOrStdin())\n\t\tif err != nil {\n\t\t\treturn nil, false, fmt.Errorf(\"read --%s-stdin: %w\", prefix, err)\n\t\t}\n\t\traw = string(buf)\n\t\tif strings.TrimSpace(raw) == \"\" {\n\t\t\treturn nil, false, fmt.Errorf(\"--%s-stdin: empty input%s\", prefix, clearHint)\n\t\t}\n\tcase fromFile:\n\t\tif filePath == \"\" {\n\t\t\treturn nil, false, fmt.Errorf(\"--%s-file: path must not be empty\", prefix)\n\t\t}\n\t\tbuf, err := os.ReadFile(filePath)\n\t\tif err != nil {\n\t\t\t// Filesystem errors may include the path but not the contents —\n\t\t\t// safe to surface via %w.\n\t\t\treturn nil, false, fmt.Errorf(\"read --%s-file: %w\", prefix, err)\n\t\t}\n\t\traw = string(buf)\n\t\tif strings.TrimSpace(raw) == \"\" {\n\t\t\treturn nil, false, fmt.Errorf(\"--%s-file %q: empty contents%s\", prefix, filePath, clearHint)\n\t\t}\n\t}\n\n\tmc, err := parseMcpJSONObject(\"--\"+prefix, raw, allowNull)","sourceCodeStart":1389,"sourceCodeEnd":1425,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_agent.go#L1389-L1425","documentation":"Thrown when the --<prefix>-stdin flag is used and the stream is read successfully but contains only whitespace. Empty input is treated as a mistake rather than an implicit clear; the message includes a hint to pass 'null' when the flag supports clearing. Validation happens entirely client-side.","triggerScenarios":"Running `multica agent update <id> --mcp-config-stdin < /dev/null`, piping an empty string (`echo '' | multica ... --mcp-config-stdin`), or piping output of a command that produced nothing.","commonSituations":"An upstream jq filter that matched nothing and printed empty output; a script variable that was never set; redirecting from an empty or truncated file; terminal users pressing Ctrl-D immediately.","solutions":["Feed an actual JSON object on stdin: echo '{\"servers\": {}}' | multica ... --mcp-config-stdin","To clear the field, pipe the literal null when the flag allows it: echo null | multica ... --mcp-config-stdin","Debug the producer: run the piped command alone and confirm it prints non-empty JSON"],"exampleFix":"# before\necho \"$CFG\" | multica agent update <id> --mcp-config-stdin   # CFG unset\n# after\nCFG='{\"servers\": {}}'\necho \"$CFG\" | multica agent update <id> --mcp-config-stdin","handlingStrategy":"validation","validationCode":"test -n \"$(printf '%s' \"$CFG\" | tr -d '[:space:]')\" || { echo \"empty config\" >&2; exit 1; }\nprintf '%s' \"$CFG\" | multica agent update <id> --mcp-config-stdin","typeGuard":null,"tryCatchPattern":null,"preventionTips":["set -u / nounset in scripts so unset variables fail early","Pipe through jq as a canary: jq '.' consumes and validates output before the CLI sees it","To clear, deliberately pipe the literal null rather than empty input"],"tags":["cli","stdin","validation","go"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}