{"record":{"id":"b9860a76f19885b5","repo":"elastic/elasticsearch","slug":"name-snippet-missing-a-language-this-is-requir","errorCode":null,"errorMessage":"{name}: Snippet missing a language. This is required by Elasticsearch's doc testing infrastructure so we be sure we don't accidentally forget to test a snippet.","messagePattern":"(.+?): Snippet missing a language\\. This is required by Elasticsearch's doc testing infrastructure so we be sure we don't accidentally forget to test a snippet\\.","errorType":"validation","errorClass":"InvalidUserDataException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/doc/SnippetBuilder.java","lineNumber":207,"sourceCode":"            testResponse,\n            testSetup,\n            testTeardown,\n            skip,\n            continued,\n            language,\n            catchPart,\n            setup,\n            teardown,\n            curl,\n            warnings,\n            skipShardsFailures,\n            name\n        );\n    }\n\n    public void validate(String content) {\n        if (language == null) {\n            throw new InvalidUserDataException(\n                name\n                    + \": \"\n                    + \"Snippet missing a language. This is required by \"\n                    + \"Elasticsearch's doc testing infrastructure so we \"\n                    + \"be sure we don't accidentally forget to test a \"\n                    + \"snippet.\"\n            );\n        }\n        assertValidCurlInput(content);\n        assertValidJsonInput(content);\n\n    }\n\n    private void assertValidCurlInput(String content) {\n        // Try to detect snippets that contain `curl`\n        if (\"sh\".equals(language) || \"shell\".equals(language)) {\n            curl = content.contains(\"curl\");\n            if (console == Boolean.FALSE && curl == false) {","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/doc/SnippetBuilder.java#L189-L225","documentation":"Thrown by SnippetBuilder.validate() when a documentation code snippet was started (e.g. a `// CONSOLE` block) but no programming language was assigned before the snippet was finalized. The doc-testing infrastructure requires every snippet to declare a language so it can route it to the correct syntax validation and test harness; a missing language means the snippet could silently skip being tested.","triggerScenarios":"A snippet block is opened with a marker like `// CONSOLE` or `// NOTCONSOLE` but the underlying asciidoc/mdx source never specified the snippet's language (typically via the source block's language attribute or a `// <lang>` directive, depending on the parser dialect). When SnippetBuilder.build()→validate() runs, `language` is still null.","commonSituations":"A doc author writes a new example block and forgets the language annotation; an asciidoc `[source,json]` attribute was typo'd or stripped during a format conversion; a snippet was copy-pasted from a non-source context.","solutions":["Add the language attribute to the source block in the doc file (e.g. `[source,json]` for asciidoc or the appropriate markdown/mdx fenced-code language tag).","Confirm the language directive the parser expects for your doc format — asciidoc and mdx use different conventions.","Re-run the doc test task for just the affected file to confirm the snippet now validates."],"exampleFix":"// before (asciidoc):\n// CONSOLE\nGET /_search\n// after:\n[source,json]\n// CONSOLE\nGET /_search","handlingStrategy":"validation","validationCode":"// Before building, assert every snippet block declares a language:\n// for each snippet: if (snippet.language == null) fail(name + \" missing language\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always annotate source blocks with a language ([source,json] in asciidoc, fenced ```json in mdx).","Use editor snippets/templates that include the language by default.","Run the doc snippet validation task locally before pushing."],"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"}