{"record":{"id":"0052967bc35f4b41","repo":"chenhg5/cc-connect","slug":"read-stdin-w","errorCode":null,"errorMessage":"read stdin: %w","messagePattern":"read stdin: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cc-connect/tuitui.go","lineNumber":149,"sourceCode":"\t\t\"mime_type\": mimeType,\n\t\t\"filename\":  name,\n\t\t\"size\":      len(data),\n\t})\n}\n\nfunc runTuiTuiPost(args []string) {\n\topts, err := parseTuiTuiArgs(args)\n\tif err != nil {\n\t\tfatalTuiTui(err)\n\t}\n\tif opts.channelID == \"\" {\n\t\tfatalTuiTui(errors.New(\"missing --channel\"))\n\t}\n\tmessage := opts.message\n\tif opts.stdin {\n\t\tdata, err := io.ReadAll(os.Stdin)\n\t\tif err != nil {\n\t\t\tfatalTuiTui(fmt.Errorf(\"read stdin: %w\", err))\n\t\t}\n\t\tmessage = string(data)\n\t}\n\tif strings.TrimSpace(message) == \"\" {\n\t\tfatalTuiTui(errors.New(\"missing --message or --stdin\"))\n\t}\n\tp, err := loadTuiTuiPlatform(opts)\n\tif err != nil {\n\t\tfatalTuiTui(err)\n\t}\n\tctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)\n\tdefer cancel()\n\tif err := p.SendChannelPost(ctx, opts.channelID, message, opts.parentID); err != nil {\n\t\tfatalTuiTui(err)\n\t}\n\tprintJSON(map[string]any{\n\t\t\"ok\":         true,\n\t\t\"channel_id\": opts.channelID,","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/tuitui.go#L131-L167","documentation":"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.","triggerScenarios":"Running `cc-connect tuitui post --stdin ...` in an environment where stdin cannot be read: closed stdin (0&lt;&amp;- or <&-), stdin attached to a closed pipe, or an I/O error on the terminal/pipe.","commonSituations":"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.","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)"],"exampleFix":"// before\ncc-connect tuitui post --channel c1 --stdin   # stdin closed in cron\n// after\necho \"deploy done\" | cc-connect tuitui post --channel c1 --stdin","handlingStrategy":"try-catch","validationCode":"[ -t 0 ] && echo \"warning: stdin is a terminal; did you forget to pipe?\" >&2","typeGuard":null,"tryCatchPattern":"if ! out=$(echo \"msg\" | cc-connect tuitui post --channel c1 --stdin 2>&1); then\n  echo \"send failed: $out\" >&2; exit 1\nfi","preventionTips":["Always pair --stdin with an explicit pipe or redirect","Avoid --stdin in cron/systemd jobs without configured stdin","Prefer --message for short fixed texts"],"tags":["cli","stdin","tuitui","io"],"backgroundTag":"file-read-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}