chenhg5/cc-connect · error
missing --message or --stdin
Error message
missing --message or --stdin
What it means
runTuiTuiPost requires message content from either --message or --stdin; after resolving both sources it checks the final message is non-empty and aborts otherwise. Posting an empty message is never allowed.
Source
Thrown at cmd/cc-connect/tuitui.go:154
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,
"parent_id": opts.parentID,
})
}
func downloadTuiTuiURL(ctx context.Context, rawURL string, maxBytes int64) ([]byte, string, string, error) {View on GitHub (pinned to 4000b2338a)
Solutions
- Provide text: add `--message "..."` or pipe data with `--stdin`
- Check the producing command in a pipeline actually emitted content before posting
- Verify the message variable is non-empty in your script
Example fix
// before cc-connect tuitui post --channel C0123 // after cc-connect tuitui post --channel C0123 --stdin < report.txt
Defensive patterns
Strategy: validation
Validate before calling
msg := message
if useStdin { b, _ := io.ReadAll(os.Stdin); msg = string(b) }
if strings.TrimSpace(msg) == "" {
return errors.New("provide --message or non-empty stdin")
} Prevention
- When piping via --stdin, check the producing command's exit status first
- Fall back to --message if the piped data is empty
- Guard script variables holding the message text
When it happens
Trigger: Running `cc-connect tuitui post --channel X` with neither --message nor --stdin, passing an empty --message, or piping empty/whitespace-only data via --stdin.
Common situations: Upstream command in a pipe produced no output (`cmd | cc-connect tuitui post --channel X --stdin` when cmd failed), a shell variable holding the text was unset, or forgot the --stdin flag while relying on a pipe.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/44d667eb59a8fab4.
Report an issue: GitHub.