chenhg5/cc-connect · error
read stdin: %w
Error message
read stdin: %w
What it means
runTuiTuiPost supports `--stdin` to read the TuiTui message body from standard input. If io.ReadAll(os.Stdin) fails, the command calls fatalTuiTui with `read stdin: %w`, aborting before any message is sent.
Source
Thrown at cmd/cc-connect/tuitui.go:149
"mime_type": mimeType,
"filename": name,
"size": len(data),
})
}
func runTuiTuiPost(args []string) {
opts, err := parseTuiTuiArgs(args)
if err != nil {
fatalTuiTui(err)
}
if opts.channelID == "" {
fatalTuiTui(errors.New("missing --channel"))
}
message := opts.message
if opts.stdin {
data, err := io.ReadAll(os.Stdin)
if err != nil {
fatalTuiTui(fmt.Errorf("read stdin: %w", err))
}
message = string(data)
}
if strings.TrimSpace(message) == "" {
fatalTuiTui(errors.New("missing --message or --stdin"))
}
p, err := loadTuiTuiPlatform(opts)
if err != nil {
fatalTuiTui(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
if err := p.SendChannelPost(ctx, opts.channelID, message, opts.parentID); err != nil {
fatalTuiTui(err)
}
printJSON(map[string]any{
"ok": true,
"channel_id": opts.channelID,View on GitHub (pinned to 4000b2338a)
Solutions
- Pipe content explicitly: `echo "msg" | cc-connect tuitui post --stdin ...` or `cc-connect tuitui post --stdin < file.txt`
- Drop --stdin and pass the text with --message instead
- In non-interactive contexts (cron, systemd), configure stdin (StandardInput=.null or feed via pipe)
Example fix
// before cc-connect tuitui post --channel c1 --stdin # stdin closed in cron // after echo "deploy done" | cc-connect tuitui post --channel c1 --stdin
Defensive patterns
Strategy: try-catch
Validate before calling
[ -t 0 ] && echo "warning: stdin is a terminal; did you forget to pipe?" >&2
Try / catch
if ! out=$(echo "msg" | cc-connect tuitui post --channel c1 --stdin 2>&1); then echo "send failed: $out" >&2; exit 1 fi
Prevention
- Always pair --stdin with an explicit pipe or redirect
- Avoid --stdin in cron/systemd jobs without configured stdin
- Prefer --message for short fixed texts
When it happens
Trigger: Running `cc-connect tuitui post --stdin ...` in an environment where stdin cannot be read: closed stdin (0<&- or <&-), stdin attached to a closed pipe, or an I/O error on the terminal/pipe.
Common situations: Piping from a command that failed and closed early, cron/systemd units with no stdin configured, accidentally passing --stdin while also expecting --message to be used in a closed-stdin shell.
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/0052967bc35f4b41.
Report an issue: GitHub.