{"record":{"id":"763d8a6bbef387c5","repo":"elastic/elasticsearch","slug":"console-not-paired-with-a-snippet","errorCode":null,"errorMessage":"CONSOLE not paired with a snippet","messagePattern":"CONSOLE not paired with a snippet","errorType":"validation","errorClass":"InvalidUserDataException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/doc/SnippetParser.java","lineNumber":227,"sourceCode":"                        snippetBuilder.withWarning(m.group(8));\n                        return;\n                    }\n                    if (m.group(9) != null) {\n                        snippetBuilder.withSkipShardsFailures(true);\n                        return;\n                    }\n                    throw new InvalidUserDataException(\"Invalid test marker: \" + line);\n                });\n            }\n            return true;\n        }\n        return false;\n    }\n\n    protected boolean consoleHandled(String line, SnippetBuilder snippet) {\n        if (line.matches(getConsoleRegex())) {\n            if (snippetBuilder == null) {\n                throw new InvalidUserDataException(\"CONSOLE not paired with a snippet\");\n            }\n            if (snippetBuilder.consoleDefined()) {\n                throw new InvalidUserDataException(\"Can't be both CONSOLE and NOTCONSOLE\");\n            }\n            snippetBuilder.withConsole(Boolean.TRUE);\n            return true;\n        } else if (line.matches(getNotconsoleRegex())) {\n            if (snippet == null) {\n                throw new InvalidUserDataException(\"NOTCONSOLE not paired with a snippet\");\n            }\n            if (snippetBuilder.consoleDefined()) {\n                throw new InvalidUserDataException(\"Can't be both CONSOLE and NOTCONSOLE\");\n            }\n            snippet.withConsole(Boolean.FALSE);\n            return true;\n        }\n        return false;\n    }","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/doc/SnippetParser.java#L209-L245","documentation":"Thrown by SnippetParser.consoleHandled() when a line matching the CONSOLE regex (e.g. `// CONSOLE`) is encountered but snippetBuilder is null — meaning there is no open snippet to mark as a console example. The CONSOLE directive's purpose is to flag the preceding/current snippet as a console (curl-style) example, so it must be associated with an active snippet.","triggerScenarios":"A `// CONSOLE` line appears in a doc file with no currently-open snippet (snippetBuilder is null). The getConsoleRegex matches and the guard fires.","commonSituations":"A CONSOLE marker is placed where there is no source block before it; the preceding snippet was closed before the marker; a copy-paste left a stray `// CONSOLE` with no associated code block.","solutions":["Ensure the `// CONSOLE` directive is positioned with an open snippet (a source code block) it can attach to — typically directly above or below the snippet per the doc format's convention.","Remove the orphaned `// CONSOLE` line if its snippet was deleted.","Verify the snippet-opening syntax is correct so the parser actually opens a snippet before reaching the CONSOLE marker."],"exampleFix":"// before:\n// CONSOLE\n// (no source block)\n// after:\n// CONSOLE\n----\nGET /_search\n----","handlingStrategy":"validation","validationCode":"// Before building, walk doc lines and ensure every // CONSOLE has an open snippet to attach to.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure `// CONSOLE` is always paired with a source code block.","Remove orphaned `// CONSOLE` markers when deleting their snippets.","Verify the doc format's snippet-opening syntax is correct."],"tags":["docs","snippet-tests","validation"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}