chenhg5/cc-connect · error
message or attachment is required
Error message
message or attachment is required
What it means
This error is returned by the Engine's session-send path when a send request is issued with an empty message body and no image or file attachments. The engine refuses to dispatch a completely empty outgoing message because platforms require at least one of text, images, or files to render a reply.
Source
Thrown at core/engine.go:11192
func (e *Engine) SendToSessionWithOptions(sessionKey, message string, images []ImageAttachment, files []FileAttachment, opts SendOptions) error {
if strings.TrimSpace(opts.WorkDir) != "" {
workDir, useWorkDirSession, err := e.resolveSendWorkDir(opts.WorkDir)
if err != nil {
return err
}
if useWorkDirSession {
return e.SendToSessionInWorkDir(sessionKey, message, images, files, workDir, opts.AtUsers, opts.AtAll)
}
}
state, p, replyCtx, err := e.resolveOutboundSessionTarget(sessionKey, len(images) > 0 || len(files) > 0)
if err != nil {
return err
}
if message == "" && len(images) == 0 && len(files) == 0 {
return fmt.Errorf("message or attachment is required")
}
if (len(images) > 0 || len(files) > 0) && !e.attachmentSendEnabled {
return ErrAttachmentSendDisabled
}
var imageSender ImageSender
if len(images) > 0 {
var ok bool
imageSender, ok = p.(ImageSender)
if !ok {
return fmt.Errorf("platform %s: %w", p.Name(), ErrNotSupported)
}
}
var fileSender FileSender
if len(files) > 0 {
var ok bool
fileSender, ok = p.(FileSender)View on GitHub (pinned to 4000b2338a)
Solutions
- Ensure at least one of message text, images, or files is non-empty before calling the send API
- Trim-check the message: if strings.TrimSpace(message)=="" && len(images)==0 && len(files)==0, abort or substitute placeholder text
- If the intent was attachment-only, verify the attachment list was actually populated (file read succeeded)
Example fix
// before
engine.SendToSession(key, msg, nil, nil, "", nil, false)
// after
if strings.TrimSpace(msg) == "" && len(imgs) == 0 && len(files) == 0 {
return fmt.Errorf("nothing to send")
}
engine.SendToSession(key, msg, imgs, files, "", nil, false) Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(message) == "" && len(images) == 0 && len(files) == 0 {
return fmt.Errorf("refusing to send: empty message and no attachments")
} Prevention
- Validate payload completeness at the call-site boundary before invoking engine send APIs
- Never build send payloads from unvalidated dynamic strings
- Unit-test send helpers with an empty-payload case
When it happens
Trigger: Calling the engine's send-to-session API (the one at core/engine.go that calls resolveOutboundSessionTarget) with message="", images=nil, files=nil — e.g. building the message from a variable that turned out empty, or trimming whitespace from the text before calling.
Common situations: Automation scripts that pass a shell variable which is empty; templates where all fields were optional and none were filled; callers that intended to send only an attachment but the attachment slice failed to populate.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- antigravity: invalid permission behavior %q
- auth.json missing tokens.access_token
- auth.json missing tokens.account_id
- tmux: 'session' option is required (name of the tmux session
- %s must be true or false
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/a6d9d43edb25891a.
Report an issue: GitHub.