alibaba/nacos · warning · IllegalArgumentException
action is blank
Error message
action is blank
What it means
Thrown by VisibilityGrantRoleHelper.normalizeStoredAction() when the action parameter is blank (null, empty, or whitespace-only). This is the raw IllegalArgumentException that DefaultVisibilityGrantService.normalizeGrantAction() catches and re-wraps as a NacosApiException (see error 1355). It is thrown directly only if normalizeStoredAction is called outside the DefaultVisibilityGrantService wrapper.
Source
Thrown at plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/visibility/VisibilityGrantRoleHelper.java:55
private static final String USER_ROLE_MARKER = "u.";
private static final int USER_ROLE_HASH_HEX_LENGTH = 32;
private VisibilityGrantRoleHelper() {
}
static String normalizeNamespaceId(String namespaceId) {
return StringUtils.isBlank(namespaceId) ? Constants.DEFAULT_NAMESPACE_ID : namespaceId;
}
static String normalizeResourceType(String resourceType) {
return StringUtils.isBlank(resourceType) ? resourceType
: resourceType.trim().toLowerCase(Locale.ROOT);
}
static String normalizeStoredAction(String action) {
if (StringUtils.isBlank(action)) {
throw new IllegalArgumentException("action is blank");
}
String normalized = action.trim().toLowerCase(Locale.ROOT);
if ("r".equals(normalized)) {
return "r";
}
if ("w".equals(normalized) || "rw".equals(normalized)) {
return "rw";
}
throw new IllegalArgumentException("unsupported action: " + action);
}
static boolean matchesRequestedAction(String storedAction, String requestedAction) {
String normalizedRequested = normalizeStoredAction(requestedAction);
if ("rw".equals(normalizedRequested)) {
return "rw".equals(storedAction);
}
return "r".equals(storedAction) || "rw".equals(storedAction);
}View on GitHub (pinned to 9b989acdf1)
Solutions
- Ensure the action parameter is non-blank before calling normalizeStoredAction.
- Prefer going through DefaultVisibilityGrantService which wraps this into a user-friendly NacosApiException.
- Add input validation at the API boundary to reject blank action values.
Example fix
// before: direct call may throw raw IllegalArgumentException
String stored = VisibilityGrantRoleHelper.normalizeStoredAction(action);
// after: validate first
if (StringUtils.isBlank(action)) {
throw new IllegalArgumentException("action is required");
}
String stored = VisibilityGrantRoleHelper.normalizeStoredAction(action); Defensive patterns
Strategy: validation
Validate before calling
// Validate action is non-blank before calling normalizeStoredAction
if (StringUtils.isBlank(action)) {
throw new IllegalArgumentException("action is required");
}
String stored = VisibilityGrantRoleHelper.normalizeStoredAction(action); Type guard
public static boolean isActionPresent(String action) {
return StringUtils.isNotBlank(action);
} Try / catch
try {
String stored = VisibilityGrantRoleHelper.normalizeStoredAction(action);
} catch (IllegalArgumentException e) {
// "action is blank" — handle missing action input
log.warn("Action normalization failed: {}", e.getMessage());
throw e;
} Prevention
- Always validate action is non-blank before calling the helper directly.
- Prefer routing through DefaultVisibilityGrantService which wraps this into a NacosApiException.
- Add input validation at the API boundary for the action field.
When it happens
Trigger: Calling VisibilityGrantRoleHelper.normalizeStoredAction(null), normalizeStoredAction(""), or normalizeStoredAction(" "). Within the normal flow, this is caught by normalizeGrantAction and converted to a NacosApiException. Direct calls to the helper (e.g. from matchesRequestedAction) will propagate this raw exception.
Common situations: A caller invokes the helper directly with unvalidated input; the action field was omitted in the API request and null-propagated to the helper.
Related errors
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/f027b8f58d6aa725.
Report an issue: GitHub.