{"record":{"id":"b1f2cc22572abe18","repo":"elastic/elasticsearch","slug":"test-not-paired-with-a-snippet-at","errorCode":null,"errorMessage":"TEST not paired with a snippet at ","messagePattern":"TEST not paired with a snippet at ","errorType":"validation","errorClass":"InvalidUserDataException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/doc/SnippetParser.java","lineNumber":179,"sourceCode":"                            snippetBuilder.withSubstitution(\"( +)\", \"$1\\\\\\\\s+\");\n                            snippetBuilder.withSubstitution(\"\\n\", \"\\\\\\\\s*\\n \");\n                        } else if (m.group(4) != null) {\n                            // TESTRESPONSE[skip:reason]\n                            snippetBuilder.withSkip(m.group(4));\n                        }\n                    }\n                );\n            }\n            return true;\n        }\n        return false;\n    }\n\n    protected boolean testHandled(String line, SnippetBuilder snippetBuilder) {\n        Matcher matcher = testPattern().matcher(line);\n        if (matcher.matches()) {\n            if (snippetBuilder == null) {\n                throw new InvalidUserDataException(\"TEST not paired with a snippet at \");\n            }\n            snippetBuilder.withTest(true);\n            if (matcher.group(2) != null) {\n                ParsingUtils.parse(matcher.group(2), TEST_SYNTAX, (Matcher m, Boolean last) -> {\n                    if (m.group(1) != null) {\n                        snippetBuilder.withCatchPart(m.group(1));\n                        return;\n                    }\n                    if (m.group(2) != null) {\n                        snippetBuilder.withSubstitution(m.group(2), m.group(3));\n                        return;\n                    }\n                    if (m.group(4) != null) {\n                        snippetBuilder.withSkip(m.group(4));\n                        return;\n                    }\n                    if (m.group(5) != null) {\n                        snippetBuilder.withContinued(true);","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/doc/SnippetParser.java#L161-L197","documentation":"Thrown by SnippetParser.testHandled() when a line matching the TEST regex is found but snippetBuilder is null — i.e. a `// TEST[...]` directive appears with no currently-open CONSOLE snippet to attach to. TEST directives express substitutions, catches, setup/teardown, and warnings against the preceding snippet; without one they are meaningless. Like error 209 the literal message ends with 'at ' and the location is supplied by the outer SnippetParserException wrapper.","triggerScenarios":"A `// TEST[...]` line is not preceded by an open `// CONSOLE` snippet block (snippet was closed, deleted, or never opened). The testPattern matches and snippetBuilder is null.","commonSituations":"A TEST directive was left behind after its CONSOLE snippet was deleted; the TEST directive was placed before (instead of after) the snippet; a copy-paste duplicated the TEST directive away from its snippet.","solutions":["Find the `// TEST` line via the outer SnippetParserException's file:line and move/delete it so it follows an open CONSOLE snippet.","If the CONSOLE snippet was intentionally removed, remove the orphaned `// TEST[...]` line too.","Check ordering: TEST directives must come after the snippet they modify, not before."],"exampleFix":"// before:\n// TEST[s/old/new/]\n// CONSOLE\nGET /old\n// after:\n// CONSOLE\nGET /old\n// TEST[s/old/new/]","handlingStrategy":"validation","validationCode":"// Before building, walk doc lines and ensure every // TEST[...] has a preceding open // CONSOLE snippet.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Place `// TEST[...]` directives after the snippet they modify.","Delete `// TEST[...]` lines when you delete their snippet.","Don't reorder snippets without reordering their TEST directives."],"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"}