chenhg5/cc-connect · error
reading stdin: %w
Error message
reading stdin: %w
What it means
When `cc-connect send --stdin` is used, parseSendArgs reads the whole of os.Stdin with io.ReadAll and wraps any read failure as "reading stdin: %w". This indicates the OS-level read of the standard input stream failed, not an empty or malformed message.
Source
Thrown at cmd/cc-connect/send.go:168
case "--at-all":
req.AtAll = true
case "--data-dir":
if i+1 >= len(args) {
return req, "", fmt.Errorf("--data-dir requires a value")
}
i++
dataDir = args[i]
case "--help", "-h":
return req, "", errSendUsage
default:
positional = append(positional, args[i])
}
}
if useStdin {
data, err := io.ReadAll(os.Stdin)
if err != nil {
return req, "", fmt.Errorf("reading stdin: %w", err)
}
req.Message = strings.TrimSpace(string(data))
}
if req.Project == "" {
req.Project = strings.TrimSpace(os.Getenv("CC_PROJECT"))
}
if req.SessionKey == "" {
req.SessionKey = strings.TrimSpace(os.Getenv("CC_SESSION_KEY"))
}
if req.Message == "" {
req.Message = strings.Join(positional, " ")
}
maxAtt := resolveMaxAttachmentSize(loadSendConfigBestEffort())
images, err := loadImageAttachments(imagePaths, maxAtt)
if err != nil {
return req, "", errView on GitHub (pinned to 4000b2338a)
Solutions
- Ensure the producer actually writes and closes successfully: `echo "msg" | cc-connect send --stdin`.
- Check the upstream command's exit status; fix its own I/O error first.
- Avoid redirecting stdin from a directory or other non-readable file; use `< /dev/null` only when not passing --stdin.
- Pass the message as an argument instead of --stdin if stdin is unreliable in your environment.
Example fix
// before some_flaky_cmd | cc-connect send --stdin // after msg=$(some_cmd) && printf '%s' "$msg" | cc-connect send --stdin
Defensive patterns
Strategy: try-catch
Validate before calling
# check upstream succeeds before piping set -o pipefail producer_cmd | cc-connect send --stdin
Try / catch
out, err := cmd.CombinedOutput()
if err != nil && strings.Contains(string(out), "reading stdin:") {
log.Printf("stdin read failed, check producer: %v", err)
} Prevention
- Use set -o pipefail to surface upstream pipe errors.
- Redirect from /dev/null explicitly when there is no input (and don't pass --stdin).
- Avoid piping from directories or special files.
- Prefer --message when stdin is unreliable in your environment.
When it happens
Trigger: `cc-connect send --stdin` where stdin is a closed/invalid descriptor, a pipe whose writer exited with an I/O error, or stdin redirected from an unreadable file.
Common situations: CI job where the upstream pipe was closed early; running under a supervisor that detached fds; piping from a command that itself failed; redirecting stdin from a directory or special file.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/f523fee9d0f70083.
Report an issue: GitHub.