{"record":{"id":"393195befa40246d","repo":"elastic/elasticsearch","slug":"missing-name-for-invalid-pattern-rule","errorCode":null,"errorMessage":"Missing [name] for invalid pattern rule","messagePattern":"Missing \\[name\\] for invalid pattern rule","errorType":"validation","errorClass":"InvalidUserDataException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ForbiddenPatternsTask.java","lineNumber":188,"sourceCode":"\n    @OutputFile\n    public File getOutputMarker() {\n        return new File(projectLayout.getBuildDirectory().getAsFile().get(), \"markers/\" + getName());\n    }\n\n    @Input\n    public Map<String, String> getPatterns() {\n        return Collections.unmodifiableMap(patterns);\n    }\n\n    public void exclude(String... excludes) {\n        filesFilter.exclude(excludes);\n    }\n\n    public void rule(Map<String, String> props) {\n        String name = props.remove(\"name\");\n        if (name == null) {\n            throw new InvalidUserDataException(\"Missing [name] for invalid pattern rule\");\n        }\n        String pattern = props.remove(\"pattern\");\n        if (pattern == null) {\n            throw new InvalidUserDataException(\"Missing [pattern] for invalid pattern rule\");\n        }\n        if (props.isEmpty() == false) {\n            throw new InvalidUserDataException(\"Unknown arguments for ForbiddenPatterns rule mapping: \" + props.keySet().toString());\n        }\n        // TODO: fail if pattern contains a newline, it won't work (currently)\n        patterns.put(name, pattern);\n    }\n\n    @Internal\n    abstract ListProperty<FileTree> getSourceFolders();\n\n    @Internal\n    abstract Property<File> getRootDir();\n","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ForbiddenPatternsTask.java#L170-L206","documentation":"Thrown by ForbiddenPatternsTask.rule(Map) when the supplied map has no 'name' key. Each forbidden-pattern rule must be named (the name keys the rule in the patterns map and is reported on violations), so a missing name is rejected as invalid user data at configuration time.","triggerScenarios":"Calling rule([pattern: '...']) or rule([:]) — any rule(Map) invocation whose map lacks the 'name' entry.","commonSituations":"A build script rule block with a typo ('Name' instead of 'name'); a copied rule missing the name line; an auto-generated rule config that omitted the name.","solutions":["Add a 'name' entry to the rule map, e.g. rule(name: 'no-tabs', pattern: '\\t').","Check for typos in the key (case-sensitive 'name').","Re-run the task to confirm configuration succeeds."],"exampleFix":"// before\nrule pattern: '\\\\t'\n\n// after\nrule name: 'no-tabs', pattern: '\\\\t'","handlingStrategy":"validation","validationCode":"// In rule(), validate keys up front\nif (!props.containsKey(\"name\")) throw new InvalidUserDataException(\"Missing [name] for invalid pattern rule\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use named-argument style in Groovy DSL (name: '...', pattern: '...') so missing keys are obvious.","Keep rule definitions together in a single block for easy review.","Lint build scripts in CI."],"tags":["gradle","forbidden-patterns","precommit","task-config","validation"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}