{"record":{"id":"fc97f0a1d3e0a8ba","repo":"multica-ai/multica","slug":"read-s-stdin-w","errorCode":null,"errorMessage":"read --%s-stdin: %w","messagePattern":"read --(.+?)-stdin: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_agent.go","lineNumber":1403,"sourceCode":"\tswitch {\n\tcase count == 0:\n\t\treturn nil, false, nil\n\tcase count > 1:\n\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)","sourceCodeStart":1385,"sourceCodeEnd":1421,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_agent.go#L1385-L1421","documentation":"Thrown when reading the --<prefix>-stdin stream with io.ReadAll fails. This means the operating system or shell failed while delivering stdin — not that the content is invalid. The underlying error is wrapped with %w so the OS cause (e.g. broken pipe, I/O error) is visible in the chain.","triggerScenarios":"Running `multica agent update <id> --mcp-config-stdin` where the producer of stdin dies mid-write (e.g. `curl ... | multica ... --mcp-config-stdin` and curl fails), reading from a closed pipe, or stdin being a descriptor in an error state.","commonSituations":"Piping a failing curl/jq/cat into the CLI; running under a process supervisor that closes stdin unexpectedly; a CI runner that provides no usable stdin and the pipe errors instead of staying open.","solutions":["Fix the upstream command in the pipe — run it alone and confirm it exits 0 before piping into the CLI","Write the payload to a file and use --<prefix>-file instead, which removes the pipe dependency","Pass the value inline with --<prefix> if it is small enough"],"exampleFix":"# before\ncurl -s https://example.com/cfg.json | multica agent update <id> --mcp-config-stdin\n# after\ncurl -fsS https://example.com/cfg.json -o /tmp/cfg.json && multica agent update <id> --mcp-config-file /tmp/cfg.json","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"In Go code embedding the CLI or equivalent pipe logic: data, err := io.ReadAll(stdin); if err != nil { log.Fatalf(\"read stdin: %v\", err) } — always branch on the error instead of assuming pipes deliver data.","preventionTips":["Use --<prefix>-file for anything fetched over the network instead of piping","Set pipefail in bash scripts so upstream failures surface before the CLI runs","Prefer files over pipes in CI where stdin handling is unreliable"],"tags":["cli","stdin","io","pipe","go"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}