elastic/elasticsearch · error · InvalidUserDataException
Can't be both CONSOLE and NOTCONSOLE
Error message
Can't be both CONSOLE and NOTCONSOLE
What it means
Thrown by SnippetParser.consoleHandled() in the CONSOLE branch when a `// CONSOLE` directive is processed but snippetBuilder.consoleDefined() is already true — meaning the snippet has already been marked CONSOLE or NOTCONSOLE. A snippet can be either console or not-console, not both; setting CONSOLE twice (or after NOTCONSOLE) is contradictory.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/doc/SnippetParser.java:230
if (m.group(9) != null) {
snippetBuilder.withSkipShardsFailures(true);
return;
}
throw new InvalidUserDataException("Invalid test marker: " + line);
});
}
return true;
}
return false;
}
protected boolean consoleHandled(String line, SnippetBuilder snippet) {
if (line.matches(getConsoleRegex())) {
if (snippetBuilder == null) {
throw new InvalidUserDataException("CONSOLE not paired with a snippet");
}
if (snippetBuilder.consoleDefined()) {
throw new InvalidUserDataException("Can't be both CONSOLE and NOTCONSOLE");
}
snippetBuilder.withConsole(Boolean.TRUE);
return true;
} else if (line.matches(getNotconsoleRegex())) {
if (snippet == null) {
throw new InvalidUserDataException("NOTCONSOLE not paired with a snippet");
}
if (snippetBuilder.consoleDefined()) {
throw new InvalidUserDataException("Can't be both CONSOLE and NOTCONSOLE");
}
snippet.withConsole(Boolean.FALSE);
return true;
}
return false;
}
protected abstract String getTestSetupRegex();
View on GitHub (pinned to db6a809a66)
Solutions
- Inspect the snippet's directives and keep only one console-status marker (either CONSOLE or NOTCONSOLE, not both, and not duplicated).
- Remove the redundant second directive so consoleDefined() is false when the surviving one is processed.
Example fix
// before: // CONSOLE // NOTCONSOLE ---- GET /_search ---- // after: // CONSOLE ---- GET /_search ----
Defensive patterns
Strategy: validation
Validate before calling
// Before building, for each snippet assert consoleDefined() is set at most once (no duplicate/conflicting CONSOLE/NOTCONSOLE).
Prevention
- Keep at most one console-status directive (CONSOLE or NOTCONSOLE) per snippet.
- After editing snippet markers, re-read the block to confirm no duplicates remain.
When it happens
Trigger: A single snippet has two console-status directives applied to it: either two `// CONSOLE` lines, or a `// CONSOLE` after a `// NOTCONSOLE`. The CONSOLE branch checks consoleDefined() before setting.
Common situations: A copy-paste duplicated the CONSOLE directive within one snippet; a snippet was edited and both CONSOLE and NOTCONSOLE directives were left on it; a migration tool emitted both markers.
Related errors
- Unexpected unconverted snippets: {foundButNotListed}
- Couldn't find the corresponding mdx file for {asciidocFileAb
- Yaml rest specs ({asciidocFile} and {mdxFile}) are not equal
- Yaml rest specs ({asciidocFile} and {mdxFile}) are not equal
- {name}: Snippet missing a language. This is required by Elas
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/d4d0f272dabdd249.
Report an issue: GitHub.