{"record":{"id":"67c9f5fb5542dd14","repo":"alibaba/nacos","slug":"invalid-dataid","errorCode":null,"errorMessage":"invalid dataId","messagePattern":"invalid dataId","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/com/alibaba/nacos/client/config/common/GroupKey.java","lineNumber":52,"sourceCode":"    private static final char B = 'B';\n    \n    private static final char FIVE = '5';\n    \n    public static String getKey(String dataId, String group) {\n        return getKey(dataId, group, \"\");\n    }\n    \n    public static String getKey(String dataId, String group, String datumStr) {\n        return doGetKey(dataId, group, datumStr);\n    }\n    \n    public static String getKeyTenant(String dataId, String group, String tenant) {\n        return doGetKey(dataId, group, tenant);\n    }\n    \n    private static String doGetKey(String dataId, String group, String datumStr) {\n        if (StringUtils.isBlank(dataId)) {\n            throw new IllegalArgumentException(\"invalid dataId\");\n        }\n        if (StringUtils.isBlank(group)) {\n            throw new IllegalArgumentException(\"invalid group\");\n        }\n        StringBuilder sb = new StringBuilder();\n        urlEncode(dataId, sb);\n        sb.append(PLUS);\n        urlEncode(group, sb);\n        if (StringUtils.isNotEmpty(datumStr)) {\n            sb.append(PLUS);\n            urlEncode(datumStr, sb);\n        }\n        \n        return sb.toString();\n    }\n    \n    /**\n     * Parse key.","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/client/src/main/java/com/alibaba/nacos/client/config/common/GroupKey.java#L34-L70","documentation":"Thrown as IllegalArgumentException by GroupKey.doGetKey() when the dataId parameter is null or blank (StringUtils.isBlank). doGetKey() is called by getKey(dataId, group), getKey(dataId, group, datumStr), and getKeyTenant(dataId, group, tenant). The group key is the internal composite key used by the Nacos config client to track configurations, so a blank dataId makes the key meaningless.","triggerScenarios":"Any call to GroupKey.getKey() or GroupKey.getKeyTenant() with a null, empty, or whitespace-only dataId. This typically happens in config listener registration, cache management, or config query paths where dataId was not validated upstream.","commonSituations":"Config listener registered with a null dataId (e.g., ConfigService.addListener(null, group, listener)). Config query via ConfigService.getConfig(null, group, timeout). Deserialization or callback code that passes an unvalidated dataId from user input or a malformed config reference.","solutions":["Validate dataId is non-blank before calling GroupKey.getKey() or before registering listeners/querying configs.","Trace upstream: find where the null/blank dataId originated — often a missing property or uninitialized field.","If dataId comes from user input or external config, add a validation guard at the API boundary."],"exampleFix":"// before\nString key = GroupKey.getKey(dataId, group); // throws if dataId is null\n\n// after: validate before composing key\nif (StringUtils.isBlank(dataId)) {\n    throw new IllegalArgumentException(\"dataId must not be blank\");\n}\nString key = GroupKey.getKey(dataId, group);","handlingStrategy":"validation","validationCode":"// Validate dataId before building a group key\nif (StringUtils.isBlank(dataId)) {\n    throw new IllegalArgumentException(\"dataId must not be null or blank\");\n}\nString key = GroupKey.getKey(dataId, group);","typeGuard":null,"tryCatchPattern":"try {\n    String key = GroupKey.getKey(dataId, group);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"invalid dataId\")) {\n        log.error(\"dataId is blank — check the caller passed a valid config dataId\");\n    }\n    throw e;\n}","preventionTips":["Validate dataId at the API boundary before passing to config operations.","Use Constants for default values rather than passing null.","Add precondition checks in service methods that accept dataId."],"tags":["nacos","config-client","group-key","validation","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}