{"record":{"id":"264cf77141c7c856","repo":"alibaba/nacos","slug":"400-264cf7","errorCode":"400","errorMessage":"tagv2 gray rule parse failed: raw string [%s] doesn't match pattern[%s].","messagePattern":"tagv2 gray rule parse failed: raw string \\[(.+?)\\] doesn't match pattern\\[(.+?)\\]\\.","errorType":"exception","errorClass":"NacosException","httpStatus":null,"severity":"error","filePath":"config/src/main/java/com/alibaba/nacos/config/server/model/gray/AbstractTagMatchGrayRule.java","lineNumber":48,"sourceCode":"    \n    protected static final String KEY_PATTERN = \"[a-zA-Z0-9-_:\\\\.]+\";\n    \n    protected static final String VALUE_SPLITER_PATTERN = \",\";\n    \n    protected static final String VALUE_PATTERN =\n        KEY_PATTERN + \"(\\\\s*\" + VALUE_SPLITER_PATTERN + \"\\\\s*\" + KEY_PATTERN + \")*\";\n    \n    public AbstractTagMatchGrayRule() {\n        super();\n    }\n    \n    public AbstractTagMatchGrayRule(String rawGrayRuleExp, int priority) {\n        super(rawGrayRuleExp, priority);\n    }\n    \n    protected void isPatternMatch(String rawString, String pattern) throws NacosException {\n        if (!rawString.matches(pattern)) {\n            throw new NacosException(NacosException.INVALID_PARAM,\n                String.format(\n                    \"tagv2 gray rule parse failed: \" + \"raw string [%s] doesn't match pattern[%s].\",\n                    rawString, pattern));\n        }\n    }\n    \n    /**\n     * Check whether another tag match gray rule has the same expression, priority, type and version.\n     *\n     * @param obj another object.\n     * @return true if equals.\n     */\n    @Override\n    public boolean equals(Object obj) {\n        if (obj == null) {\n            return false;\n        }\n        if (obj instanceof AbstractTagMatchGrayRule) {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/config/src/main/java/com/alibaba/nacos/config/server/model/gray/AbstractTagMatchGrayRule.java#L30-L66","documentation":"Thrown by AbstractTagMatchGrayRule.isPatternMatch when the raw gray rule string does not match the expected regex pattern. Returns NacosException code 400 (INVALID_PARAM). The pattern for tag rules is key=value(s) where key matches [a-zA-Z0-9-_:\\.]+ and value matches the same class optionally comma-separated. This is the base check inherited by both single-tag and multi-tag rules.","triggerScenarios":"Publishing a tag gray config whose grayRuleExp contains characters outside [a-zA-Z0-9-_:\\.], or whose structure (key=value) is malformed — e.g. missing '=' , empty key, or special symbols in values. Triggered during rule parsing when the gray is published.","commonSituations":"Rule expression built from unescaped user input containing spaces or symbols; copy-paste from a non-tag rule type; mismatched grayType (using a single-tag expression for multi-tag).","solutions":["Ensure the rule expression matches key=value format with only allowed characters [a-zA-Z0-9-_:\\.] in keys and values.","For multi-value rules use comma separation: key=v1,v2,v3.","Validate the expression against the KEY_PATTERN and VALUE_PATTERN regex before submitting."],"exampleFix":"// before\ngrayRuleExp = \"zone = us east 1\"  // spaces and missing pattern\n// after\ngrayRuleExp = \"zone=us-east-1\"","handlingStrategy":"validation","validationCode":"private static final Pattern RULE =\n    Pattern.compile(\"^[a-zA-Z0-9-_:\\\\.]+=[a-zA-Z0-9-_:\\\\.]+(,[a-zA-Z0-9-_:\\\\.]+)*$\");\nif (!RULE.matcher(grayRuleExp.trim()).matches()) {\n    throw new IllegalArgumentException(\"invalid tag gray rule expression\");\n}","typeGuard":null,"tryCatchPattern":"try { configApi.publishGray(form); }\ncatch (NacosException e) {\n    if (e.getErrCode() == NacosException.INVALID_PARAM)\n        { /* fix rule expression */ } else throw e;\n}","preventionTips":["Restrict gray rule keys/values to [a-zA-Z0-9-_:\\.].","Validate the expression client-side against the pattern before publish."],"tags":["config","gray-release","tag-rule","validation","invalid-param"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}