alibaba/nacos · error · IllegalArgumentException
Prompt is required
Error message
Prompt is required
What it means
Thrown by PromptOptimizationForm.validate() (copilot module) when the `prompt` field is null, empty, or whitespace-only. This form backs the POST /v3/console/copilot/prompt/optimize SSE endpoint. The original prompt is mandatory because the AI needs source material to optimize; optimizationGoal is optional.
Source
Thrown at copilot/src/main/java/com/alibaba/nacos/copilot/form/PromptOptimizationForm.java:44
public class PromptOptimizationForm {
/**
* Original Prompt content (required).
*/
private String prompt;
/**
* Optimization goal/requirement description (optional).
* e.g., "Make response more concise", "Add more examples", "Support multi-language"
*/
private String optimizationGoal;
/**
* Validate form data.
*/
public void validate() {
if (StringUtils.isBlank(prompt)) {
throw new IllegalArgumentException("Prompt is required");
}
}
public String getPrompt() {
return prompt;
}
public void setPrompt(String prompt) {
this.prompt = prompt;
}
public String getOptimizationGoal() {
return optimizationGoal;
}
public void setOptimizationGoal(String optimizationGoal) {
this.optimizationGoal = optimizationGoal;
}View on GitHub (pinned to 9b989acdf1)
Solutions
- Send a non-blank `prompt` string in the request body.
- Keep the client-side trim guard and replicate it for any API client.
- If the prompt comes from a variable, ensure it resolves to non-empty content.
Example fix
// before
body: JSON.stringify({ prompt: template, optimizationGoal: optimizeGoal })
// after
if (!template.trim()) {
setOptimizeError('Prompt template is empty');
return;
}
body: JSON.stringify({ prompt: template, optimizationGoal: optimizeGoal }) Defensive patterns
Strategy: validation
Validate before calling
function hasPrompt(prompt: unknown): boolean {
return typeof prompt === 'string' && prompt.trim().length > 0;
} Prevention
- Include a non-blank prompt in the optimize request body.
- Keep the client-side template.trim() guard and replicate it for API clients.
- Validate that template variables resolve to non-empty content.
When it happens
Trigger: Posting to /v3/console/copilot/prompt/optimize with an empty/whitespace/null `prompt` field. The front-end handlers guard `if (!template.trim()) return;` but direct API callers can send an empty prompt.
Common situations: User clears the template then clicks optimize. Programmatic call with an empty prompt body. Template variable resolving to empty.
Related errors
- Prompt is required
- User input is required
- Background information is required
- Skill is required
- Skill name is required
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/a46321569437f5d2.
Report an issue: GitHub.