{"record":{"id":"f658c5b330886095","repo":"elastic/elasticsearch","slug":"name-no-need-for-notconsole-if-snippet-doesn-t","errorCode":null,"errorMessage":"{name}: No need for NOTCONSOLE if snippet doesn't contain `curl`.","messagePattern":"(.+?): No need for NOTCONSOLE if snippet doesn't contain `curl`\\.","errorType":"validation","errorClass":"InvalidUserDataException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/doc/SnippetBuilder.java","lineNumber":226,"sourceCode":"                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) {\n                throw new InvalidUserDataException(name + \": \" + \"No need for NOTCONSOLE if snippet doesn't \" + \"contain `curl`.\");\n            }\n        }\n    }\n\n    private void assertValidJsonInput(String content) {\n        if (testResponse && (\"js\" == language || \"console-result\" == language) && null == skip) {\n            String quoted = content\n                // quote values starting with $\n                .replaceAll(\"([:,])\\\\s*(\\\\$[^ ,\\\\n}]+)\", \"$1 \\\"$2\\\"\")\n                // quote fields starting with $\n                .replaceAll(\"(\\\\$[^ ,\\\\n}]+)\\\\s*:\", \"\\\"$1\\\":\");\n\n            JsonFactory jf = new JsonFactory();\n            jf.configure(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER, true);\n            JsonParser jsonParser;\n\n            try {\n                jsonParser = jf.createParser(quoted);","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/doc/SnippetBuilder.java#L208-L244","documentation":"Thrown by SnippetBuilder.assertValidCurlInput() when a snippet is tagged `NOTCONSOLE` (i.e. `console = false`) but its language is `sh`/`shell` AND the snippet body does not contain the text `curl`. The NOTCONSOLE marker only makes sense for shell snippets that would otherwise be treated as console examples because they contain `curl`; a non-curl shell snippet has no reason to be marked NOTCONSOLE, so the build flags it as a contradictory/misleading annotation.","triggerScenarios":"A doc snippet has language `sh` or `shell`, includes a `// NOTCONSOLE` directive, but the snippet text does not include the substring `curl`. The validation logic sets `curl = content.contains(\"curl\")` and then checks `console == FALSE && curl == false`.","commonSituations":"A contributor adds `// NOTCONSOLE` defensively or by copy-paste to a plain shell snippet that never had a curl command; a snippet's curl command was removed but the NOTCONSOLE marker was left behind.","solutions":["Remove the `// NOTCONSOLE` directive from the snippet — it is unnecessary for a non-curl shell snippet.","If the snippet was meant to contain a curl command, add the curl invocation back to the snippet body.","Double-check the language is genuinely `sh`/`shell`; if it is a different language the NOTCONSOLE marker is also irrelevant and should be removed."],"exampleFix":"// before:\n// NOTCONSOLE\n----\necho hello\n----\n// after:\n----\necho hello\n----","handlingStrategy":"validation","validationCode":"// Before building, for sh/shell snippets check:\n// if (\"sh\".equals(lang) || \"shell\".equals(lang)) {\n//   boolean hasCurl = content.contains(\"curl\");\n//   if (console==Boolean.FALSE && !hasCurl) fail(\"NOTCONSOLE without curl\");\n// }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only add `// NOTCONSOLE` to shell snippets that actually contain `curl`.","Remove NOTCONSOLE markers whenever you remove a curl command from a snippet.","Don't copy `// NOTCONSOLE` from another snippet by habit."],"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"}