{"record":{"id":"1b9f9e32deee52d0","repo":"alibaba/nacos","slug":"20002","errorCode":"20002","errorMessage":"Request parameter `scope` must be PUBLIC or PRIVATE.","messagePattern":"Request parameter `scope` must be PUBLIC or PRIVATE\\.","errorType":"validation","errorClass":"NacosApiException","httpStatus":400,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/form/AiResourceFilterableForm.java","lineNumber":80,"sourceCode":"     * When {@code null} or empty, no scope filter is applied and both public and private\n     * resources that the caller is authorized to see are returned.</p>\n     */\n    private String scope;\n    \n    /**\n     * Optional filter by business tag.\n     *\n     * <p>When specified, only resources whose {@code bizTags} column contains the given value\n     * are returned (fuzzy match). When {@code null} or empty, no bizTag filter is applied.</p>\n     */\n    private String bizTag;\n    \n    @Override\n    public void validate() throws NacosApiException {\n        if (StringUtils.isNotBlank(scope)\n            && !VisibilityConstants.SCOPE_PUBLIC.equalsIgnoreCase(scope)\n            && !VisibilityConstants.SCOPE_PRIVATE.equalsIgnoreCase(scope)) {\n            throw new NacosApiException(NacosException.INVALID_PARAM,\n                ErrorCode.PARAMETER_VALIDATE_ERROR,\n                \"Request parameter `scope` must be PUBLIC or PRIVATE.\");\n        }\n    }\n    \n    public String getOwner() {\n        return owner;\n    }\n    \n    public void setOwner(String owner) {\n        this.owner = owner;\n    }\n    \n    public String getScope() {\n        return scope;\n    }\n    \n    public void setScope(String scope) {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/form/AiResourceFilterableForm.java#L62-L98","documentation":"Thrown by AgentValidationUtils.validateAgentName when the name is 1-64 chars long and every character is printable ASCII (0x20-0x7E) but contains no character above 0x20 (i.e. it is all spaces). The same 'Invalid agentName' text is also used at line 89 (null/empty/>64) and line 95 (out-of-range char), but line 102 specifically rejects all-whitespace names. The validator requires at least one visible character.","triggerScenarios":"Submitting an Agent create/update form (AgentAdminForm.validate at ai/.../form/agent/admin/AgentAdminForm.java:44) or calling AgentPersistenceService/AgentOperationService with agentName set to whitespace only (e.g. \"   \"). Also RadAsciiAgentIdCodec.decode when an encoded agent id decodes to an all-space name.","commonSituations":"Trimming is applied at the wrong layer so spaces survive to the validator; a UI field auto-filled with spaces; copy-paste of a name that ended up entirely spaces; test fixtures using \" \" as a placeholder.","solutions":["Trim the agentName and confirm at least one non-space printable ASCII character remains before submitting.","Reject blank/whitespace input at the controller/form boundary so it never reaches AgentValidationUtils.","Restrict agentName to [A-Za-z0-9 _-]-style tokens of 1-64 chars."],"exampleFix":"// before\nform.setAgentName(\"   \");\n// after\nString name = form.getAgentName() == null ? \"\" : form.getAgentName().trim();\nif (name.isEmpty()) {\n    throw new IllegalArgumentException(\"agentName is required\");\n}\nform.setAgentName(name);","handlingStrategy":"validation","validationCode":"String name = agentName == null ? null : agentName.trim();\nif (name == null || name.isEmpty() || name.length() > 64\n        || !name.matches(\"^[\\\\x20-\\\\x7E]*$\")\n        || name.chars().allMatch(c -> c == 0x20)) {\n    throw new IllegalArgumentException(\"Invalid agentName\");\n}","typeGuard":"static boolean isValidAgentName(String s) {\n    return s != null && !s.isEmpty() && s.length() <= 64\n        && s.chars().allMatch(c -> c >= 0x20 && c <= 0x7E)\n        && s.chars().anyMatch(c -> c > 0x20);\n}","tryCatchPattern":"try {\n    AgentValidationUtils.validateAgentName(agentName);\n} catch (IllegalArgumentException e) {\n    // map to HTTP 400 with field 'agentName'\n}","preventionTips":["Trim and reject blank names at the controller/form boundary.","Unit-test the validator with all-whitespace and Unicode inputs."],"tags":["ai-agent","validation","agent-name","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}