{"record":{"id":"4f0fa375d81f7ed2","repo":"alibaba/nacos","slug":"capturing-patterns-name-are-not-supported-by-t","errorCode":null,"errorMessage":"Capturing patterns ({name}) are not supported by the AntPathMatcher. Use the PathPatternParser instead.","messagePattern":"Capturing patterns \\((.+?)\\) are not supported by the AntPathMatcher\\. Use the PathPatternParser instead\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/com/alibaba/nacos/common/packagescan/resource/AntPathMatcher.java","lineNumber":606,"sourceCode":"         * @return {@code true} if the string matches against the pattern, or {@code false} otherwise.\n         */\n        public boolean matchStrings(String str, Map<String, String> uriTemplateVariables) {\n            if (this.exactMatch) {\n                return this.caseSensitive ? this.rawPattern.equals(str) : this.rawPattern.equalsIgnoreCase(str);\n            } else if (this.pattern != null) {\n                Matcher matcher = this.pattern.matcher(str);\n                if (matcher.matches()) {\n                    if (uriTemplateVariables != null) {\n                        if (this.variableNames.size() != matcher.groupCount()) {\n                            throw new IllegalArgumentException(\"The number of capturing groups in the pattern segment \"\n                                    + this.pattern + \" does not match the number of URI template variables it defines, \"\n                                    + \"which can occur if capturing groups are used in a URI template regex. \"\n                                    + \"Use non-capturing groups instead.\");\n                        }\n                        for (int i = 1; i <= matcher.groupCount(); i++) {\n                            String name = this.variableNames.get(i - 1);\n                            if (name.startsWith(\"*\")) {\n                                throw new IllegalArgumentException(\"Capturing patterns (\" + name + \") are not \"\n                                        + \"supported by the AntPathMatcher. Use the PathPatternParser instead.\");\n                            }\n                            String value = matcher.group(i);\n                            uriTemplateVariables.put(name, value);\n                        }\n                    }\n                    return true;\n                }\n            }\n            return false;\n        }\n\n    }\n\n    /**\n     * A simple cache for patterns that depend on the configured path separator.\n     */\n    private static class PathSeparatorPatternCache {","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/common/src/main/java/com/alibaba/nacos/common/packagescan/resource/AntPathMatcher.java#L588-L624","documentation":"AntPathMatcher rejects URI-template variables whose declared name begins with `*` (e.g. `{*path}`). Such a name denotes a greedy catch-all capture in Spring's PathPatternParser, a feature AntPathMatcher deliberately does not implement. The matcher detects the asterisk prefix and aborts rather than emit ambiguous or wrong bindings.","triggerScenarios":"Matching a path against a pattern containing a `{*...}` token while a uriTemplateVariables map is passed in (the extraction branch). The check `name.startsWith(\"*\")` fires on the first such variable encountered during the value-binding loop.","commonSituations":"Porting a PathPatternParser-style mapping (`/resources/**{*tail}`) into AntPathMatcher configuration. Using `/files/{*file}` to capture a multi-segment remainder. Documentation or examples that mix the two matcher dialects.","solutions":["Remove the `*` prefix from the variable name; use a normal `{var}` and handle multi-segment matching with `/**` suffix instead.","Switch to PathPatternParser if a catch-all capture variable is genuinely required by your routing logic.","Audit pattern strings coming from external config/YAML for stray `{*` tokens before they reach the matcher."],"exampleFix":"// before\nString pattern = \"/files/{*file}\"; // catch-all capture, unsupported\n\n// after\nString pattern = \"/files/**\"; // match remainder without capture, supported","handlingStrategy":"validation","validationCode":"static String rejectCatchAllVar(String pattern) {\n    int i;\n    while ((i = pattern.indexOf(\"{*\")) >= 0) {\n        throw new IllegalArgumentException(\n            \"AntPathMatcher does not support {*var}; fix pattern: \" + pattern);\n    }\n    return pattern;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Scan every pattern string for the literal `{*` before registering it with AntPathMatcher.","Reserve `{*...}` for PathPatternParser configurations only.","Use `/**` suffix instead of `{*remainder}` for trailing catch-all matching."],"tags":["antpathmatcher","uri-template","wildcard","resource-matching","validation"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}