alibaba/nacos · warning · NacosApiException

PARAMETER_MISSING

PARAMETER_MISSING

Error message

resourceType is blank

What it means

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.

Source

Thrown at plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/visibility/DefaultVisibilityGrantService.java:234

            return;
        }
        String currentUsername = AuthIdentityUtils.resolveCurrentUsername();
        if (AuthIdentityUtils.isCurrentIdentityGlobalAdmin(currentUsername)) {
            return;
        }
        if (StringUtils.isNotBlank(currentUsername)
            && currentUsername.equals(resource.getOwner())) {
            return;
        }
        throw new NacosApiException(NacosException.NO_RIGHT, ErrorCode.ACCESS_DENIED,
            "No permission to manage visibility grants for resource: "
                + resource.getResourceName());
    }
    
    private void validateResourceTypeAndName(String resourceType, String resourceName)
        throws NacosException {
        if (StringUtils.isBlank(resourceType)) {
            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.PARAMETER_MISSING,
                "resourceType is blank");
        }
        if (StringUtils.isBlank(resourceName)) {
            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.PARAMETER_MISSING,
                "resourceName is blank");
        }
    }
    
    private void validateUsername(String username) throws NacosException {
        if (StringUtils.isBlank(username)) {
            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.PARAMETER_MISSING,
                "username is blank");
        }
    }
    
    private void validateGranteeExists(String username) throws NacosException {
        User grantee = userService.getUser(username);
        if (grantee == null) {

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Ensure the API request includes a non-blank resourceType (e.g. 'config', 'service').
  2. Add client-side and server-side validation for the resourceType field before it reaches the visibility service.
  3. Check the API request payload to confirm resourceType is present and non-empty.

Example fix

// Validate at the controller/form layer before calling the service:
if (StringUtils.isBlank(resourceType)) {
    throw new NacosApiException(NacosException.INVALID_PARAM,
        ErrorCode.PARAMETER_MISSING, "resourceType is required");
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate resourceType at the API boundary
if (StringUtils.isBlank(resourceType)) {
    return Result.failure("resourceType is required");
}

Type guard

public static boolean isValidResourceType(String resourceType) {
    return StringUtils.isNotBlank(resourceType);
}

Try / catch

try {
    service.grant(namespaceId, resourceType, resourceName, username, action);
} catch (NacosApiException e) {
    if (e.getDetailErrCode() == ErrorCode.PARAMETER_MISSING.getCode()) {
        return Result.failure("Missing required parameter: " + e.getMessage());
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/06cddfb8f4f10b4f. Report an issue: GitHub.