alibaba/nacos · error · IllegalArgumentException

Prompt is required

Error message

Prompt is required

What it means

Thrown by PromptDebugForm.validate() (copilot module) when the `prompt` field is null, empty, or whitespace-only. PromptDebugForm backs the POST /v3/console/copilot/prompt/debug SSE endpoint; the prompt template is mandatory because it defines the AI behavior under test. The controller calls form.validate() immediately and sends an SSE error event on failure.

Source

Thrown at copilot/src/main/java/com/alibaba/nacos/copilot/form/PromptDebugForm.java:45

    
    /**
     * System Prompt content (required).
     * This is the prompt template that defines the AI's behavior.
     */
    private String prompt;
    
    /**
     * User input content (required).
     * This is the user's message to test with the prompt.
     */
    private String userInput;
    
    /**
     * Validate form data.
     */
    public void validate() {
        if (StringUtils.isBlank(prompt)) {
            throw new IllegalArgumentException("Prompt is required");
        }
        if (StringUtils.isBlank(userInput)) {
            throw new IllegalArgumentException("User input is required");
        }
    }
    
    public String getPrompt() {
        return prompt;
    }
    
    public void setPrompt(String prompt) {
        this.prompt = prompt;
    }
    
    public String getUserInput() {
        return userInput;
    }
    

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Ensure the `prompt` field in the request body is a non-blank string before sending.
  2. On the client, disable the debug button when the rendered prompt is blank.
  3. If using template variables, verify they resolve to non-empty values.

Example fix

// before
body: JSON.stringify({ prompt: renderedPrompt, userInput })

// after
if (!renderedPrompt.trim()) {
  setDebugError('Prompt template is empty');
  return;
}
body: JSON.stringify({ prompt: renderedPrompt, userInput })
Defensive patterns

Strategy: validation

Validate before calling

function isValidDebugForm(prompt: unknown, userInput: unknown): boolean {
  return typeof prompt === 'string' && prompt.trim().length > 0
      && typeof userInput === 'string' && userInput.trim().length > 0;
}

Prevention

When it happens

Trigger: Posting to /v3/console/copilot/prompt/debug with an empty/null/whitespace `prompt` field in the JSON body, or omitting the field entirely. The front-end debug handler guards userInput.trim() but only checks template indirectly, so a blank rendered prompt can reach the server.

Common situations: Prompt template variable resolves to empty. User clears the template field then clicks debug. API client built without the prompt field. Variable substitution producing whitespace-only output.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/353c92f3d4b67718. Report an issue: GitHub.