{"record":{"id":"ab583bf4dcff9c3d","repo":"theonedev/onedev","slug":"malformed-pattern-set","errorCode":null,"errorMessage":"Malformed pattern set","messagePattern":"Malformed pattern set","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/util/patternset/PatternSet.java","lineNumber":87,"sourceCode":"    \t\tfiles.add(new File(dir, path));\n    \t\n\t\treturn files;\n\t}\n\t\n\tpublic static PatternSet parse(@Nullable String patternSetString) {\n\t\tSet<String> includes = new HashSet<>();\n\t\tSet<String> excludes = new HashSet<>();\n\t\t\n\t\tif (patternSetString != null) {\n\t\t\tCharStream is = CharStreams.fromString(patternSetString); \n\t\t\tPatternSetLexer lexer = new PatternSetLexer(is);\n\t\t\tlexer.removeErrorListeners();\n\t\t\tlexer.addErrorListener(new BaseErrorListener() {\n\n\t\t\t\t@Override\n\t\t\t\tpublic void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,\n\t\t\t\t\t\tint charPositionInLine, String msg, RecognitionException e) {\n\t\t\t\t\tthrow new RuntimeException(\"Malformed pattern set\");\n\t\t\t\t}\n\t\t\t\t\n\t\t\t});\n\t\t\tCommonTokenStream tokens = new CommonTokenStream(lexer);\n\t\t\tPatternSetParser parser = new PatternSetParser(tokens);\n\t\t\tparser.removeErrorListeners();\n\t\t\tparser.setErrorHandler(new BailErrorStrategy());\n\t\t\t\n\t\t\tPatternsContext patternsContext = parser.patterns();\n\t\t\t\n\t\t\tfor (PatternContext pattern: patternsContext.pattern()) {\n\t\t\t\tString value;\n\t\t\t\tif (pattern.Quoted() != null) \n\t\t\t\t\tvalue = FenceAware.unfence(pattern.Quoted().getText());\n\t\t\t\telse \n\t\t\t\t\tvalue = pattern.NQuoted().getText();\n\t\t\t\tvalue = StringUtils.unescape(value);\n\t\t\t\tif (pattern.Excluded() != null)","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/util/patternset/PatternSet.java#L69-L105","documentation":"PatternSet parses its pattern-set definition with an ANTLR grammar; a custom error listener replaces the default one and throws RuntimeException('Malformed pattern set') on any lexer/parser syntax error. This means the pattern-set text does not conform to the expected syntax (e.g. malformed include/exclude patterns, bad wildcards, stray characters).","triggerScenarios":"Providing a pattern-set string (e.g. in file-matching/CI configuration) whose syntax the PatternSet grammar rejects — unbalanced characters, illegal wildcards like '***', malformed '**/' sequences, or stray separators in include/exclude lines.","commonSituations":"Hand-written glob patterns with unsupported syntax; pasting patterns from other tools (e.g. .gitignore or regex) that use constructs the pattern-set grammar does not accept; typos like missing '*' or stray spaces/quotes in the config field.","solutions":["Review the pattern-set string and fix syntax errors — use the supported glob forms (e.g. '**/*.java', 'docs/*') with correct include/exclude syntax.","Simplify the pattern: remove unsupported constructs (regex-only syntax, triple stars, stray characters).","Test the pattern incrementally: start with a simple valid pattern and add complexity until the failure reappears.","Consult OneDev pattern-set documentation for the exact accepted grammar and rewrite the patterns accordingly."],"exampleFix":"// before\nString patterns = \"src/**/*.java\\n!**/*Test{,s}.java\"; // brace expansion unsupported\n// after\nString patterns = \"src/**/*.java\\n!**/*Test.java\\n!**/*Tests.java\";","handlingStrategy":"validation","validationCode":"boolean simplePatternOk(String patterns) {\n    // basic sanity: no obviously unsupported constructs\n    return patterns != null && !patterns.matches(\".*(\\\\*\\\\*\\\\*|\\\\{).*\") ;\n}","typeGuard":null,"tryCatchPattern":"try {\n    PatternSet set = PatternSet.parse(patternText);\n} catch (RuntimeException e) {\n    if (\"Malformed pattern set\".equals(e.getMessage())) {\n        // fall back to a safe default pattern set or surface config error\n    } else throw e;\n}","preventionTips":["Stick to documented glob syntax; avoid regex or brace-expansion constructs.","Build pattern sets incrementally and validate after each edit.","Copy patterns only from sources using the same pattern-set grammar."],"tags":["pattern-matching","glob-syntax","configuration"],"backgroundTag":"invalid-config-value","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}