{"record":{"id":"b5adef99aab8c688","repo":"multica-ai/multica","slug":"read-stdin-for-s-w","errorCode":null,"errorMessage":"read stdin for --%s: %w","messagePattern":"read stdin for --(.+?): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_issue.go","lineNumber":64,"sourceCode":"\n\tsources := 0\n\tif useStdin {\n\t\tsources++\n\t}\n\tif inline != \"\" {\n\t\tsources++\n\t}\n\tif filePath != \"\" {\n\t\tsources++\n\t}\n\tif sources > 1 {\n\t\treturn \"\", false, fmt.Errorf(\"--%s, --%s, and --%s are mutually exclusive\", flagName, stdinFlag, fileFlag)\n\t}\n\n\tif useStdin {\n\t\tdata, err := io.ReadAll(os.Stdin)\n\t\tif err != nil {\n\t\t\treturn \"\", false, fmt.Errorf(\"read stdin for --%s: %w\", stdinFlag, err)\n\t\t}\n\t\tbody := strings.TrimSuffix(string(data), \"\\n\")\n\t\tif body == \"\" {\n\t\t\treturn \"\", false, fmt.Errorf(\"stdin content for --%s is empty\", stdinFlag)\n\t\t}\n\t\treturn body, true, nil\n\t}\n\tif filePath != \"\" {\n\t\tif err := ensureFileFlagWithinWorkdir(cmd, fileFlag, flagName, filePath); err != nil {\n\t\t\treturn \"\", false, err\n\t\t}\n\t\tdata, err := os.ReadFile(filePath)\n\t\tif err != nil {\n\t\t\treturn \"\", false, fmt.Errorf(\"read file for --%s: %w\", fileFlag, err)\n\t\t}\n\t\tbody := strings.TrimSuffix(string(data), \"\\n\")\n\t\tif body == \"\" {\n\t\t\treturn \"\", false, fmt.Errorf(\"file content for --%s is empty\", fileFlag)","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_issue.go#L46-L82","documentation":"Returned by the shared text-source helper when reading os.Stdin for a --flag-stdin variant fails at the OS level (io.ReadAll error). The %s names the stdin flag and %w carries the underlying syscall error, such as a closed descriptor or an I/O failure on the pipe.","triggerScenarios":"Using --flag-stdin where stdin cannot be read: the descriptor is closed (0<&-), the pipe was broken because the producer exited early, or redirection points to an unreadable target. Distinct from empty stdin, which produces the separate 'stdin content is empty' error.","commonSituations":"Shell scripts closing stdin explicitly; CI jobs with no stdin attached combined with a stdin flag; echo ... | head truncations that break the pipe; cron contexts where stdin is /dev/null-unavailable or closed.","solutions":["Inspect the wrapped error to identify the I/O cause, then fix the redirection or pipe feeding the command","Ensure stdin is an open, readable descriptor when using any --*-stdin flag (e.g. pipe a file: multica issue create --description-stdin < desc.txt)","If stdin is genuinely unavailable, use the inline flag or --flag-file instead","In scripts, avoid closing stdin (0<&-) on commands that consume it"],"exampleFix":"# before\nmultica issue create --title \"T\" --description-stdin 0<&-\n# error: read stdin for --description-stdin: <syscall error>\n\n# after\nmultica issue create --title \"T\" --description-stdin < description.txt","handlingStrategy":"try-catch","validationCode":"// bash: verify stdin is readable before invoking a --*-stdin flag\nif ! { true <&0; } 2>/dev/null; then\n    echo \"stdin is not readable\" >&2; exit 1\nfi","typeGuard":null,"tryCatchPattern":"// Go callers of the CLI: distinguish I/O failure from empty input\n// by checking the wrapped *os.PathError / syscall error.\nif err := runCLI(args); err != nil {\n    if strings.Contains(err.Error(), \"read stdin for --\") {\n        // environment problem: fix descriptors/redirection, do not retry blindly\n    }\n}","preventionTips":["Never close stdin on commands that consume it","Redirect a real file (< file.txt) rather than relying on inherited descriptors in cron/CI contexts"],"tags":["cli","stdin","io","flags"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}