{"record":{"id":"926c0f433fa669cd","repo":"alibaba/nacos","slug":"invalid-groupkey-groupkey","errorCode":null,"errorMessage":"invalid groupkey:{groupKey}","messagePattern":"invalid groupkey:(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/com/alibaba/nacos/client/config/common/GroupKey.java","lineNumber":91,"sourceCode":"     * @return parsed key\n     */\n    public static String[] parseKey(String groupKey) {\n        StringBuilder sb = new StringBuilder();\n        String dataId = null;\n        String group = null;\n        String tenant = null;\n        \n        for (int i = 0; i < groupKey.length(); ++i) {\n            char c = groupKey.charAt(i);\n            if (PLUS == c) {\n                if (null == dataId) {\n                    dataId = sb.toString();\n                    sb.setLength(0);\n                } else if (null == group) {\n                    group = sb.toString();\n                    sb.setLength(0);\n                } else {\n                    throw new IllegalArgumentException(\"invalid groupkey:\" + groupKey);\n                }\n            } else if (PERCENT == c) {\n                char next = groupKey.charAt(++i);\n                char nextnext = groupKey.charAt(++i);\n                if (TWO == next && B == nextnext) {\n                    sb.append(PLUS);\n                } else if (TWO == next && FIVE == nextnext) {\n                    sb.append(PERCENT);\n                } else {\n                    throw new IllegalArgumentException(\"invalid groupkey:\" + groupKey);\n                }\n            } else {\n                sb.append(c);\n            }\n        }\n        \n        if (group == null) {\n            group = sb.toString();","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/client/src/main/java/com/alibaba/nacos/client/config/common/GroupKey.java#L73-L109","documentation":"Thrown as IllegalArgumentException by GroupKey.parseKey() when the group key string contains more than two unescaped '+' delimiters. parseKey() splits on '+' into at most three parts (dataId, group, tenant). A third '+' means the key has a fourth segment, which is structurally invalid. This indicates the key string was constructed or corrupted incorrectly.","triggerScenarios":"Calling GroupKey.parseKey() on a string that contains more than two literal '+' characters. This can happen if the key was assembled manually (not via getKey()), if a dataId/group/tenant contained an unescaped '+', or if the key string was truncated/concatenated incorrectly. The urlEncode() method escapes '+' as '%2B', so a raw '+' surviving into the key means encoding was bypassed.","commonSituations":"Manually building group key strings with string concatenation instead of GroupKey.getKey(). DataId, group, or tenant containing '+' that was not URL-encoded before being used in a key. Interoperability between systems that handle '+' differently. Corrupted or truncated cache keys.","solutions":["Always use GroupKey.getKey() or getKeyTenant() to build keys — never manual string concatenation with '+'.","If the key was built externally, URL-encode any '+' characters in dataId/group/tenant before assembling.","Log the full groupKey value to identify which component contains the extra '+'.","If parsing a key from an external/legacy source, validate its structure before calling parseKey()."],"exampleFix":"// before: manual concatenation can produce extra '+' delimiters\nString key = dataId + \"+\" + group + \"+\" + tenant; // unsafe if values contain '+'\nString[] parts = GroupKey.parseKey(key); // may throw\n\n// after: always use GroupKey to build keys\nString key = GroupKey.getKeyTenant(dataId, group, tenant); // encodes '+' as %2B\nString[] parts = GroupKey.parseKey(key); // safe","handlingStrategy":"validation","validationCode":"// Validate group key structure before parsing\n// A valid key has at most 2 unescaped '+' delimiters\nlong plusCount = groupKey.chars().filter(c -> c == '+').count();\nif (plusCount > 2) {\n    throw new IllegalArgumentException(\"Group key has too many '+' separators: \" + groupKey);\n}\nString[] parts = GroupKey.parseKey(groupKey);","typeGuard":null,"tryCatchPattern":"try {\n    String[] parts = GroupKey.parseKey(groupKey);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"invalid groupkey\")) {\n        log.error(\"Malformed group key '{}': too many '+' separators or unescaped characters\",\n            groupKey);\n    }\n    throw e;\n}","preventionTips":["Always build keys via GroupKey.getKey() or getKeyTenant() — never manual concatenation.","If keys come from external sources, validate their structure before parsing.","Ensure dataId/group/tenant values do not contain raw '+' characters."],"tags":["nacos","config-client","group-key","validation","illegal-argument","encoding"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}