Skip to content

when (mistakenly) sending empty message the session stop with the error: text cannot be empty. #7493

Closed

Description

@avifenesh

Description

When (mistakenly) sending an empty message the session stops with the error: Text cannot be empty.
Better behaviour:
A. Ignoring and continuing with the session
B. Blocking empty messages from being sent.

If it sounds like a better UX, I will happily contribute the fix myself.

Plugins

No response

OpenCode version

1.1.7

Steps to reproduce

start a session, give it some tasks that require few steps, then few spaces and send

Screenshot and/or share link

No response

Operating System

Windows11

Terminal

Windows terminal

Activity

  1. phongndo commented on Feb 23, 2026

    @phongndo

    I’d like to work on this issue. I’ll investigate and open a PR.

  2. phongndo commented on Feb 23, 2026

    @phongndo

    Quick update after digging in:

    I reproduced this locally in TUI. Sending a whitespace-only message creates a user text part that reaches the provider unchanged, which then returns a 400 (text cannot be empty) and ends that turn.

    I’m planning to fix it by:

    • blocking/ignoring whitespace-only submits in TUI before request dispatch
    • adding a backend guard so empty-after-trim text parts can’t reach providers from any client path
    • preserving valid attachment-only prompts
    • adding regression coverage

    If this plan is good, I will link a pr.

  3. phongndo commented on Feb 23, 2026

    @phongndo

    Implemented in #14767.

    This fixes the empty-message bug by:

    • blocking whitespace-only submits in TUI with a warning toast (Message cannot be empty)
    • rejecting text-only whitespace prompt payloads at API validation with 400 (Prompt cannot be empty)
    • keeping attachment-only prompts valid

    Also added regression tests for prompt schema + session route validation.

    Fixes #7493.

    @avifenesh could you confirm this matches the desired behavior?

    Image
  4. github-actions commented on Apr 25, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions