{"record":{"id":"71764842fbd67d07","repo":"elastic/elasticsearch","slug":"didn-t-match-pattern-content","errorCode":null,"errorMessage":"Didn't match ${pattern}: ${content}","messagePattern":"Didn't match (.+?): (.+?)","errorType":"validation","errorClass":"InvalidUserDataException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/doc/ParsingUtils.java","lineNumber":49,"sourceCode":"     * matchers each time there is a match. If there are characters that don't\n     * match then blow up. If the closure takes two parameters then the second\n     * one is \"is this the last match?\".\n     */\n    static void parse(String content, String pattern, BiConsumer<Matcher, Boolean> testHandler) {\n        if (content == null) {\n            return; // Silly null, only real stuff gets to match!\n        }\n        Matcher m = Pattern.compile(pattern).matcher(content);\n        int offset = 0;\n        while (m.find()) {\n            if (m.start() != offset) {\n                extraContent(\"between [$offset] and [${m.start()}]\", content, offset, pattern);\n            }\n            offset = m.end();\n            testHandler.accept(m, offset == content.length());\n        }\n        if (offset == 0) {\n            throw new InvalidUserDataException(\"Didn't match \" + pattern + \": \" + content);\n        }\n        if (offset != content.length()) {\n            extraContent(\"after [\" + offset + \"]\", content, offset, pattern);\n        }\n    }\n\n}\n","sourceCodeStart":31,"sourceCodeEnd":57,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/doc/ParsingUtils.java#L31-L57","documentation":"ParsingUtils.parse compiles the pattern against the content and enters the match loop. If offset stays 0 after the loop, no match was found at all — the entire snippet content failed to match the CONSOLE syntax grammar even once. This is distinct from extra_content (partial match) because here the regex matched nothing.","triggerScenarios":"A snippet marked as a test (// CONSOLE or console language) has a body that contains zero valid HTTP request lines, comments, or yaml blocks — e.g. an empty snippet body, or a body containing only text that none of the method/path/yaml/comment alternatives can match.","commonSituations":"An empty console snippet, a snippet where the opening line uses a method not in the allowed set (GET|PUT|POST|HEAD|OPTIONS|DELETE), or a snippet whose content was accidentally cleared during editing.","solutions":["Check the content shown in the message and add at least one valid request line (e.g. 'GET /_search').","If the snippet should be empty/non-executable, mark it with the appropriate snippet attribute (e.g. // NOTCONSOLE) instead of leaving it as a console test.","Verify the snippet opening delimiter in the asciidoc/mdx source is correct so content is actually captured."],"exampleFix":"// before — empty console snippet produces no match\n// CONSOLE\n\n// after — add a valid request\n// CONSOLE\nGET /_cluster/health","handlingStrategy":"validation","validationCode":"// Ensure every console snippet has at least one parseable request\nimport java.util.regex.Pattern;\n\nprivate static final Pattern HAS_REQUEST = Pattern.compile(\n    \"(GET|PUT|POST|HEAD|OPTIONS|DELETE)\\\\s+\\\\S+|#|startyaml\");\n\nvoid checkNonEmptyConsole(String contents, String snippetPath) {\n    if (!HAS_REQUEST.matcher(contents).find()) {\n        throw new IllegalStateException(\n            \"Console snippet in \" + snippetPath + \" has no valid request, comment, or yaml block: \"\n            + contents);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave a // CONSOLE snippet body empty.","If a snippet is illustrative/non-executable, mark it // NOTCONSOLE instead of // CONSOLE.","Verify snippet delimiters in asciidoc/mdx source are correctly placed so content is captured."],"tags":["docs","parsing","snippet","regex","console"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}