multica-ai/multica · error

read stdin for --%s: %w

Error message

read stdin for --%s: %w

What it means

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.

Source

Thrown at server/cmd/multica/cmd_issue.go:64

	sources := 0
	if useStdin {
		sources++
	}
	if inline != "" {
		sources++
	}
	if filePath != "" {
		sources++
	}
	if sources > 1 {
		return "", false, fmt.Errorf("--%s, --%s, and --%s are mutually exclusive", flagName, stdinFlag, fileFlag)
	}

	if useStdin {
		data, err := io.ReadAll(os.Stdin)
		if err != nil {
			return "", false, fmt.Errorf("read stdin for --%s: %w", stdinFlag, err)
		}
		body := strings.TrimSuffix(string(data), "\n")
		if body == "" {
			return "", false, fmt.Errorf("stdin content for --%s is empty", stdinFlag)
		}
		return body, true, nil
	}
	if filePath != "" {
		if err := ensureFileFlagWithinWorkdir(cmd, fileFlag, flagName, filePath); err != nil {
			return "", false, err
		}
		data, err := os.ReadFile(filePath)
		if err != nil {
			return "", false, fmt.Errorf("read file for --%s: %w", fileFlag, err)
		}
		body := strings.TrimSuffix(string(data), "\n")
		if body == "" {
			return "", false, fmt.Errorf("file content for --%s is empty", fileFlag)

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Inspect the wrapped error to identify the I/O cause, then fix the redirection or pipe feeding the command
  2. Ensure stdin is an open, readable descriptor when using any --*-stdin flag (e.g. pipe a file: multica issue create --description-stdin < desc.txt)
  3. If stdin is genuinely unavailable, use the inline flag or --flag-file instead
  4. In scripts, avoid closing stdin (0<&-) on commands that consume it

Example fix

# before
multica issue create --title "T" --description-stdin 0<&-
# error: read stdin for --description-stdin: <syscall error>

# after
multica issue create --title "T" --description-stdin < description.txt
Defensive patterns

Strategy: try-catch

Validate before calling

// bash: verify stdin is readable before invoking a --*-stdin flag
if ! { true <&0; } 2>/dev/null; then
    echo "stdin is not readable" >&2; exit 1
fi

Try / catch

// Go callers of the CLI: distinguish I/O failure from empty input
// by checking the wrapped *os.PathError / syscall error.
if err := runCLI(args); err != nil {
    if strings.Contains(err.Error(), "read stdin for --") {
        // environment problem: fix descriptors/redirection, do not retry blindly
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/b5adef99aab8c688. Report an issue: GitHub.