{"record":{"id":"353c92f3d4b67718","repo":"alibaba/nacos","slug":"prompt-is-required","errorCode":null,"errorMessage":"Prompt is required","messagePattern":"Prompt is required","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"copilot/src/main/java/com/alibaba/nacos/copilot/form/PromptDebugForm.java","lineNumber":45,"sourceCode":"    \n    /**\n     * System Prompt content (required).\n     * This is the prompt template that defines the AI's behavior.\n     */\n    private String prompt;\n    \n    /**\n     * User input content (required).\n     * This is the user's message to test with the prompt.\n     */\n    private String userInput;\n    \n    /**\n     * Validate form data.\n     */\n    public void validate() {\n        if (StringUtils.isBlank(prompt)) {\n            throw new IllegalArgumentException(\"Prompt is required\");\n        }\n        if (StringUtils.isBlank(userInput)) {\n            throw new IllegalArgumentException(\"User input is required\");\n        }\n    }\n    \n    public String getPrompt() {\n        return prompt;\n    }\n    \n    public void setPrompt(String prompt) {\n        this.prompt = prompt;\n    }\n    \n    public String getUserInput() {\n        return userInput;\n    }\n    ","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/copilot/src/main/java/com/alibaba/nacos/copilot/form/PromptDebugForm.java#L27-L63","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the `prompt` field in the request body is a non-blank string before sending.","On the client, disable the debug button when the rendered prompt is blank.","If using template variables, verify they resolve to non-empty values."],"exampleFix":"// before\nbody: JSON.stringify({ prompt: renderedPrompt, userInput })\n\n// after\nif (!renderedPrompt.trim()) {\n  setDebugError('Prompt template is empty');\n  return;\n}\nbody: JSON.stringify({ prompt: renderedPrompt, userInput })","handlingStrategy":"validation","validationCode":"function isValidDebugForm(prompt: unknown, userInput: unknown): boolean {\n  return typeof prompt === 'string' && prompt.trim().length > 0\n      && typeof userInput === 'string' && userInput.trim().length > 0;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Send a non-blank prompt field in the request body.","Disable the debug button until the rendered prompt is non-empty.","Ensure template variables resolve to non-empty content."],"tags":["copilot","prompt-debug","java","validation","form"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}