{"record":{"id":"32e42119245e9315","repo":"alibaba/nacos","slug":"invalid-tag","errorCode":null,"errorMessage":"invalid tag : {}","messagePattern":"invalid tag : (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"config/src/main/java/com/alibaba/nacos/config/server/utils/ParamUtils.java","lineNumber":137,"sourceCode":"            throw new NacosApiException(HttpStatus.BAD_REQUEST.value(),\n                ErrorCode.PARAMETER_VALIDATE_ERROR,\n                \"invalid dataId : \" + dataId);\n        }\n        if (StringUtils.isBlank(group) || !isValid(group)) {\n            throw new NacosApiException(HttpStatus.BAD_REQUEST.value(),\n                ErrorCode.PARAMETER_VALIDATE_ERROR,\n                \"invalid group : \" + group);\n        }\n        checkTenantV2(namespaceId);\n    }\n    \n    /**\n     * Check the tag for [v1].\n     */\n    public static void checkParam(String tag) {\n        if (StringUtils.isNotBlank(tag)) {\n            if (!isValid(tag.trim())) {\n                throw new IllegalArgumentException(\"invalid tag : \" + tag);\n            }\n            if (tag.length() > TAG_MAX_LEN) {\n                throw new IllegalArgumentException(\"too long tag, over 16\");\n            }\n        }\n    }\n    \n    /**\n     * Check the config info for [v1] and [v2].\n     */\n    public static void checkParam(Map<String, Object> configAdvanceInfo) throws NacosException {\n        for (Map.Entry<String, Object> configAdvanceInfoTmp : configAdvanceInfo.entrySet()) {\n            if (CONFIG_TAGS.equals(configAdvanceInfoTmp.getKey())) {\n                if (configAdvanceInfoTmp.getValue() != null) {\n                    String[] tagArr = ((String) configAdvanceInfoTmp.getValue()).split(\",\");\n                    if (tagArr.length > 5) {\n                        throw new NacosApiException(HttpStatus.BAD_REQUEST.value(),\n                            ErrorCode.PARAMETER_VALIDATE_ERROR,","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/config/src/main/java/com/alibaba/nacos/config/server/utils/ParamUtils.java#L119-L155","documentation":"Thrown by the v1 single-tag overload ParamUtils.checkParam(String tag) as an IllegalArgumentException (NOT a NacosApiException) when tag.trim() fails isValid(). No error code or HTTP status is attached; it is a raw runtime exception. Tags must use only letters, digits, and '_' '-' '.' ':'.","triggerScenarios":"Calling a v1 config operation that passes a tag containing spaces or special characters (e.g. 'tag with space', 'tag/1', 'tag@2'). Only reached when tag is non-blank.","commonSituations":"Using a human-readable label with spaces as a tag, embedding a version with '@' or '/', or copying a tag from a URL query string that includes encoded chars.","solutions":["Sanitize the tag to the allowed charset [A-Za-z0-9_.-:] before calling the v1 API.","Prefer the v2 API (checkParamV2) which returns a structured NacosApiException instead of an unchecked exception.","Pass null/blank tag when no tag is needed."],"exampleFix":"// before\nParamUtils.checkParam(\"release v1.2/tag\");\n\n// after\nString tag = \"release-v1-2-tag\"; // whitelist-safe\nParamUtils.checkParam(tag);","handlingStrategy":"validation","validationCode":"private static final Pattern TAG = Pattern.compile(\"^[A-Za-z0-9_.\\\\-:]+$\");\nboolean validTag(String tag) {\n    return tag == null || tag.isBlank() || (TAG.matcher(tag.trim()).matches() && tag.length() <= 16);\n}","typeGuard":null,"tryCatchPattern":"try {\n    ParamUtils.checkParam(tag);\n} catch (IllegalArgumentException e) {\n    // v1 throws unchecked; convert to a user-facing validation error\n    handleInvalidTag(e.getMessage());\n}","preventionTips":["Prefer the v2 API (checkParamV2) which returns structured NacosApiException.","Sanitize tags to the whitelist charset before calling.","Treat IllegalArgumentException from v1 checks as input validation errors, not system faults."],"tags":["config","validation","tag","v1","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}