quarkusio/quarkus · error · IllegalStateException

You have to specify userMessage that will be send to AI, or

Error message

You have to specify userMessage that will be send to AI, or implement your own using the function

What it means

AssistantConsoleBuildItem.Builder.build() requires either a userMessage (sent to the AI) or a custom function implementation; if userMessage is null and function is empty it throws this IllegalStateException. The build item must define what happens when the user triggers the console entry.

Source

Thrown at extensions/assistant/deployment-spi/src/main/java/io/quarkus/assistant/deployment/spi/AssistantConsoleBuildItem.java:125

            return this;
        }

        public Builder function(Function<Assistant, CompletionStage<?>> function) {
            this.function = Optional.of(function);
            return this;
        }

        public AssistantConsoleBuildItem build() {
            if (key == Character.MIN_VALUE) {
                throw new IllegalStateException(
                        "You have to specify a key. This is the key the user will press to get to your function");
            }
            if (description == null || description.isBlank()) {
                throw new IllegalStateException(
                        "You have to specify a description. This is what the user will see in the console menu");
            }
            if (userMessage == null && !function.isPresent()) {
                throw new IllegalStateException(
                        "You have to specify userMessage that will be send to AI, or implement your own using the function");
            }

            return new AssistantConsoleBuildItem(this);
        }
    }

    public ConsoleCommand getConsoleCommand() {
        return consoleCommand;
    }

    public String getDescription() {
        return consoleCommand != null ? consoleCommand.getDescription() : description;
    }

    public char getKey() {
        return key;
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Call .userMessage("...") with the prompt to send to the AI, or
  2. Call .function(...) with a custom implementation (e.g. a BiConsumer/Function handling the request yourself)

Example fix

// before
new AssistantConsoleBuildItem.Builder()
    .key('e').description("Explain")
    .build();
// after
new AssistantConsoleBuildItem.Builder()
    .key('e').description("Explain")
    .userMessage("Explain this build error")
    .build();
Defensive patterns

Strategy: validation

Validate before calling

if (userMessage == null && function.isEmpty()) {
    throw new IllegalArgumentException("Provide userMessage or function for the assistant console entry");
}

Try / catch

try {
    AssistantConsoleBuildItem item = builder.build();
} catch (IllegalStateException e) {
    logger.error("Set userMessage(...) or function(...) on the builder", e);
}

Prevention

When it happens

Trigger: Building an AssistantConsoleBuildItem with key and description set but neither userMessage(...) nor function(...) called.

Common situations: Extension authors scaffolding a console entry and planning to fill in the AI prompt later; switching between userMessage and function styles and dropping both.

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/76ab32cca0a3211e. Report an issue: GitHub.