{"record":{"id":"e812f8a6ae92e772","repo":"alibaba/nacos","slug":"20002-e812f8","errorCode":"20002","errorMessage":"Parameter 'scope' must be PUBLIC or PRIVATE","messagePattern":"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/agentspecs/admin/AgentSpecScopeForm.java","lineNumber":48,"sourceCode":" * @author nacos\n */\npublic class AgentSpecScopeForm extends AgentSpecForm {\n    \n    @Serial\n    private static final long serialVersionUID = 1L;\n    \n    private String scope;\n    \n    @Override\n    public void validate() throws NacosApiException {\n        super.validate();\n        if (StringUtils.isBlank(scope)) {\n            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.PARAMETER_MISSING,\n                \"Required parameter 'scope' type String is not present\");\n        }\n        if (!VisibilityConstants.SCOPE_PUBLIC.equalsIgnoreCase(scope)\n            && !VisibilityConstants.SCOPE_PRIVATE.equalsIgnoreCase(scope)) {\n            throw new NacosApiException(NacosException.INVALID_PARAM,\n                ErrorCode.PARAMETER_VALIDATE_ERROR,\n                \"Parameter 'scope' must be PUBLIC or PRIVATE\");\n        }\n    }\n    \n    public String getScope() {\n        return scope;\n    }\n    \n    public void setScope(String scope) {\n        this.scope = scope;\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":62,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/form/agentspecs/admin/AgentSpecScopeForm.java#L30-L62","documentation":"Thrown by AgentSpecScopeForm.validate() when `scope` is present but is neither PUBLIC nor PRIVATE (case-insensitive). This is the value-domain check that runs after the presence check. It maps to error code 20002 (PARAMETER_VALIDATE_ERROR) and HTTP 400. The valid values are defined in VisibilityConstants (SCOPE_PUBLIC=\"PUBLIC\", SCOPE_PRIVATE=\"PRIVATE\").","triggerScenarios":"Calling PUT /v3/admin/ai/agentspecs/scope with scope=public-readonly, scope=shared, scope=internal, or any value other than PUBLIC/PRIVATE. Comparison is case-insensitive so 'public' and 'Public' pass.","commonSituations":"Client hardcodes an older/different scope vocabulary (e.g. 'READONLY', 'TEAM'); typo in a config file; passing a numeric or boolean representation.","solutions":["Set scope to exactly PUBLIC or PRIVATE (any case).","Audit the calling code/config for the scope value being sent and correct it to one of the two allowed constants.","Document the allowed set in the client's API wrapper to prevent recurrence."],"exampleFix":"// before (fails)\nscope=public-readonly\n// after\nscope=PUBLIC","handlingStrategy":"validation","validationCode":"if (!\"PUBLIC\".equalsIgnoreCase(scope) && !\"PRIVATE\".equalsIgnoreCase(scope)) {\n    throw new IllegalArgumentException(\"scope must be PUBLIC or PRIVATE\");\n}","typeGuard":"static boolean isValidScope(String s) {\n    return \"PUBLIC\".equalsIgnoreCase(s) || \"PRIVATE\".equalsIgnoreCase(s);\n}","tryCatchPattern":"catch (NacosApiException e) {\n    if (e.getErrCode() == 20002) { /* invalid scope value */ }\n}","preventionTips":["Constrain the UI to a dropdown of the two allowed scope values.","Reject unknown scope values client-side before sending."],"tags":["validation","ai","agentspec","visibility","parameter","http","api"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}