{"record":{"id":"f027b8f58d6aa725","repo":"alibaba/nacos","slug":"action-is-blank","errorCode":null,"errorMessage":"action is blank","messagePattern":"action is blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/visibility/VisibilityGrantRoleHelper.java","lineNumber":55,"sourceCode":"    private static final String USER_ROLE_MARKER = \"u.\";\n    \n    private static final int USER_ROLE_HASH_HEX_LENGTH = 32;\n    \n    private VisibilityGrantRoleHelper() {\n    }\n    \n    static String normalizeNamespaceId(String namespaceId) {\n        return StringUtils.isBlank(namespaceId) ? Constants.DEFAULT_NAMESPACE_ID : namespaceId;\n    }\n    \n    static String normalizeResourceType(String resourceType) {\n        return StringUtils.isBlank(resourceType) ? resourceType\n            : resourceType.trim().toLowerCase(Locale.ROOT);\n    }\n    \n    static String normalizeStoredAction(String action) {\n        if (StringUtils.isBlank(action)) {\n            throw new IllegalArgumentException(\"action is blank\");\n        }\n        String normalized = action.trim().toLowerCase(Locale.ROOT);\n        if (\"r\".equals(normalized)) {\n            return \"r\";\n        }\n        if (\"w\".equals(normalized) || \"rw\".equals(normalized)) {\n            return \"rw\";\n        }\n        throw new IllegalArgumentException(\"unsupported action: \" + action);\n    }\n    \n    static boolean matchesRequestedAction(String storedAction, String requestedAction) {\n        String normalizedRequested = normalizeStoredAction(requestedAction);\n        if (\"rw\".equals(normalizedRequested)) {\n            return \"rw\".equals(storedAction);\n        }\n        return \"r\".equals(storedAction) || \"rw\".equals(storedAction);\n    }","sourceCodeStart":37,"sourceCodeEnd":73,"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/VisibilityGrantRoleHelper.java#L37-L73","documentation":"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.","triggerScenarios":"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.","commonSituations":"A caller invokes the helper directly with unvalidated input; the action field was omitted in the API request and null-propagated to the helper.","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."],"exampleFix":"// before: direct call may throw raw IllegalArgumentException\nString stored = VisibilityGrantRoleHelper.normalizeStoredAction(action);\n\n// after: validate first\nif (StringUtils.isBlank(action)) {\n    throw new IllegalArgumentException(\"action is required\");\n}\nString stored = VisibilityGrantRoleHelper.normalizeStoredAction(action);","handlingStrategy":"validation","validationCode":"// Validate action is non-blank before calling normalizeStoredAction\nif (StringUtils.isBlank(action)) {\n    throw new IllegalArgumentException(\"action is required\");\n}\nString stored = VisibilityGrantRoleHelper.normalizeStoredAction(action);","typeGuard":"public static boolean isActionPresent(String action) {\n    return StringUtils.isNotBlank(action);\n}","tryCatchPattern":"try {\n    String stored = VisibilityGrantRoleHelper.normalizeStoredAction(action);\n} catch (IllegalArgumentException e) {\n    // \"action is blank\" — handle missing action input\n    log.warn(\"Action normalization failed: {}\", e.getMessage());\n    throw e;\n}","preventionTips":["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."],"tags":["auth","visibility","validation","action-normalization"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}