{"record":{"id":"04b6525c5b38abe1","repo":"alibaba/nacos","slug":"skill-name-is-required","errorCode":null,"errorMessage":"Skill name is required","messagePattern":"Skill name is required","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"copilot/src/main/java/com/alibaba/nacos/copilot/form/SkillOptimizationForm.java","lineNumber":69,"sourceCode":"     */\n    private ConversationHistory conversationHistory;\n    \n    /**\n     * Target file name to optimize (optional).\n     * If specified, only optimize the content of this specific file.\n     * If not specified, optimize the entire Skill.\n     */\n    private String targetFileName;\n    \n    /**\n     * Validate form data.\n     */\n    public void validate() {\n        if (skill == null) {\n            throw new IllegalArgumentException(\"Skill is required\");\n        }\n        if (StringUtils.isBlank(skill.getName())) {\n            throw new IllegalArgumentException(\"Skill name is required\");\n        }\n    }\n    \n    public Skill getSkill() {\n        return skill;\n    }\n    \n    public void setSkill(Skill skill) {\n        this.skill = skill;\n    }\n    \n    public String getOptimizationGoal() {\n        return optimizationGoal;\n    }\n    \n    public void setOptimizationGoal(String optimizationGoal) {\n        this.optimizationGoal = optimizationGoal;\n    }","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/copilot/src/main/java/com/alibaba/nacos/copilot/form/SkillOptimizationForm.java#L51-L87","documentation":"Thrown by SkillOptimizationForm.validate() when the `skill` object is non-null but its `name` field is blank. This is the second check in the validate() chain (after the null-skill check). A Skill without a name cannot be identified or optimized, so the form rejects it.","triggerScenarios":"Posting to /v3/console/copilot/skill/optimize with a skill object whose getName() returns null, empty, or whitespace. The skill object itself is present but malformed/incomplete.","commonSituations":"Skill loaded from a partial source missing the name field. Client constructs a Skill object without setting the name. Name field deserialized as null from JSON missing 'name'.","solutions":["Ensure the skill object has a non-blank `name` field before posting.","Populate the name when constructing/loading the Skill model.","Validate the skill structure client-side before enabling optimize."],"exampleFix":"// before\nbody: JSON.stringify({ skill: currentSkill, optimizationGoal })\n\n// after\nif (!currentSkill?.name?.trim()) {\n  setError('Skill name is missing');\n  return;\n}\nbody: JSON.stringify({ skill: currentSkill, optimizationGoal })","handlingStrategy":"validation","validationCode":"function skillHasName(skill: { name?: string } | null | undefined): boolean {\n  return !!skill && typeof skill.name === 'string' && skill.name.trim().length > 0;\n}","typeGuard":"function isNamedSkill(value: unknown): value is { name: string } {\n  return value !== null && typeof value === 'object'\n    && typeof (value as any).name === 'string' && (value as any).name.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Ensure the skill object carries a non-blank name before posting.","Populate the name when constructing/loading the Skill model.","Validate skill structure client-side before enabling optimize."],"tags":["copilot","skill-optimize","java","validation","form"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}