quarkusio/quarkus · error · IllegalStateException

User message is required

Error message

User message is required

What it means

Assistant.RequestBuilder.assist() throws this IllegalStateException when userMessage was never set or is blank. The assistant API requires an actual user prompt to send to the AI backend; delegating with an empty message would be meaningless.

Source

Thrown at extensions/assistant/runtime-dev/src/main/java/io/quarkus/assistant/runtime/dev/Assistant.java:125

        public AssistBuilder addPath(Path path) {
            if (path != null) {
                this.paths.add(path);
            }
            return this;
        }

        public AssistBuilder responseType(Class<?> responseType) {
            if (responseType != null) {
                this.responseType = responseType;
            }
            return this;
        }

        @SuppressWarnings("unchecked")
        public <T> CompletionStage<T> assist() {
            if (null == userMessage || userMessage.isBlank()) {
                throw new IllegalStateException("User message is required");
            }
            return (CompletionStage<T>) assistant.assist(systemMessage, userMessage, variables, paths, responseType);
        }
    }

}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Call .userMessage("...") with non-blank text before assist()
  2. Guard the call site: only build/assist when user input is non-blank
  3. Surface a validation error to the UI/user instead of invoking the assistant

Example fix

// before
assistant.request().systemMessage(sys).assist();
// after
if (userInput != null && !userInput.isBlank()) {
    assistant.request().systemMessage(sys).userMessage(userInput).assist();
}
Defensive patterns

Strategy: validation

Validate before calling

if (userInput == null || userInput.isBlank()) {
    throw new IllegalArgumentException("userMessage must be non-blank before calling assist()");
}

Type guard

boolean hasUserMessage(Assistant.RequestBuilder b, String msg) {
    return msg != null && !msg.isBlank();
}

Try / catch

try {
    CompletionStage<String> result = builder.assist();
} catch (IllegalStateException e) {
    logger.warn("No user message provided to assistant");
}

Prevention

When it happens

Trigger: Calling assist() on the builder without calling userMessage(...) or after userMessage("") / whitespace-only input.

Common situations: Building requests programmatically where the user input was empty; forgetting to chain userMessage while setting systemMessage/variables/paths; passing optional user text straight through without a check.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/77ba99778dc30675. Report an issue: GitHub.