{"record":{"id":"06cddfb8f4f10b4f","repo":"alibaba/nacos","slug":"parameter-missing-06cddf","errorCode":"PARAMETER_MISSING","errorMessage":"resourceType is blank","messagePattern":"resourceType is blank","errorType":"validation","errorClass":"NacosApiException","httpStatus":400,"severity":"warning","filePath":"plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/visibility/DefaultVisibilityGrantService.java","lineNumber":234,"sourceCode":"            return;\n        }\n        String currentUsername = AuthIdentityUtils.resolveCurrentUsername();\n        if (AuthIdentityUtils.isCurrentIdentityGlobalAdmin(currentUsername)) {\n            return;\n        }\n        if (StringUtils.isNotBlank(currentUsername)\n            && currentUsername.equals(resource.getOwner())) {\n            return;\n        }\n        throw new NacosApiException(NacosException.NO_RIGHT, ErrorCode.ACCESS_DENIED,\n            \"No permission to manage visibility grants for resource: \"\n                + resource.getResourceName());\n    }\n    \n    private void validateResourceTypeAndName(String resourceType, String resourceName)\n        throws NacosException {\n        if (StringUtils.isBlank(resourceType)) {\n            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.PARAMETER_MISSING,\n                \"resourceType is blank\");\n        }\n        if (StringUtils.isBlank(resourceName)) {\n            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.PARAMETER_MISSING,\n                \"resourceName is blank\");\n        }\n    }\n    \n    private void validateUsername(String username) throws NacosException {\n        if (StringUtils.isBlank(username)) {\n            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.PARAMETER_MISSING,\n                \"username is blank\");\n        }\n    }\n    \n    private void validateGranteeExists(String username) throws NacosException {\n        User grantee = userService.getUser(username);\n        if (grantee == null) {","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/visibility/DefaultVisibilityGrantService.java#L216-L252","documentation":"Thrown by DefaultVisibilityGrantService.validateResourceTypeAndName() when the resourceType parameter is blank (null, empty, or whitespace-only). This is a precondition validation that runs before any resource lookup or authorization check. The error code is INVALID_PARAM with ErrorCode.PARAMETER_MISSING.","triggerScenarios":"Calling grant() or revoke() with resourceType set to null, empty string, or a whitespace-only string. This indicates a programming error in the caller — the API contract requires a non-blank resource type.","commonSituations":"A client omits the resourceType field in the API request; a form binding fails to populate the field; a programmatic caller passes a default/null value for resourceType.","solutions":["Ensure the API request includes a non-blank resourceType (e.g. 'config', 'service').","Add client-side and server-side validation for the resourceType field before it reaches the visibility service.","Check the API request payload to confirm resourceType is present and non-empty."],"exampleFix":"// Validate at the controller/form layer before calling the service:\nif (StringUtils.isBlank(resourceType)) {\n    throw new NacosApiException(NacosException.INVALID_PARAM,\n        ErrorCode.PARAMETER_MISSING, \"resourceType is required\");\n}","handlingStrategy":"validation","validationCode":"// Validate resourceType at the API boundary\nif (StringUtils.isBlank(resourceType)) {\n    return Result.failure(\"resourceType is required\");\n}","typeGuard":"public static boolean isValidResourceType(String resourceType) {\n    return StringUtils.isNotBlank(resourceType);\n}","tryCatchPattern":"try {\n    service.grant(namespaceId, resourceType, resourceName, username, action);\n} catch (NacosApiException e) {\n    if (e.getDetailErrCode() == ErrorCode.PARAMETER_MISSING.getCode()) {\n        return Result.failure(\"Missing required parameter: \" + e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Add @NotBlank validation on the resourceType field in request form models.","Validate all required parameters at the controller layer before calling the service.","Return clear field-level error messages to the API client."],"tags":["auth","visibility","validation","parameter-missing"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}