elastic/elasticsearch · error · GradleException
Yaml rest specs ({asciidocFile} and {mdxFile}) are not equal
Error message
Yaml rest specs ({asciidocFile} and {mdxFile}) are not equal, different line count What it means
Thrown by the same asciidoc/mdx parity check after both YAML files are read. If the asciidoc spec and its mdx counterpart have a different number of lines, the two cannot be byte-equivalent, so the build fails listing both file paths. This catches migrations where a line was dropped or duplicated when copying the spec.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/doc/RestTestsFromDocSnippetTask.java:525
public void finishLastTest() {
if (current != null) {
current.close();
current = null;
}
}
}
private void assertEqualTestSnippetFromMigratedDocs() {
getTestRoot().getAsFileTree().matching(patternSet -> { patternSet.include("**/*asciidoc.yml"); }).forEach(asciidocFile -> {
File mdxFile = new File(asciidocFile.getAbsolutePath().replace(".asciidoc.yml", ".mdx.yml"));
if (mdxFile.exists() == false) {
throw new InvalidUserDataException("Couldn't find the corresponding mdx file for " + asciidocFile.getAbsolutePath());
}
try {
List<String> asciidocLines = Files.readAllLines(asciidocFile.toPath());
List<String> mdxLines = Files.readAllLines(mdxFile.toPath());
if (asciidocLines.size() != mdxLines.size()) {
throw new GradleException(
"Yaml rest specs ("
+ asciidocFile.toPath()
+ " and "
+ mdxFile.getAbsolutePath()
+ ") are not equal, different line count"
);
}
for (int i = 0; i < asciidocLines.size(); i++) {
if (asciidocLines.get(i)
.replaceAll("line_\\d+", "line_0")
.equals(mdxLines.get(i).replaceAll("line_\\d+", "line_0")) == false) {
throw new GradleException(
"Yaml rest specs ("
+ asciidocFile.toPath()
+ " and "
+ mdxFile.getAbsolutePath()
+ ") are not equal, difference on line: "View on GitHub (pinned to db6a809a66)
Solutions
- Open both files side by side (the paths are in the message) and reconcile the line counts so they match.
- Diff the two files with `diff <asciidoc> <mdx>` to see exactly which lines were added or removed.
- Re-generate the mdx file from the asciidoc source using the project's migration tooling if available, rather than editing by hand.
Example fix
# before: asciidoc.yml has 12 lines, mdx.yml has 11 # after: add the missing line to mdx.yml so both have 12
Defensive patterns
Strategy: validation
Validate before calling
// Before building, assert line counts match:
// long a = Files.lines(asciidoc.toPath()).count();
// long m = Files.lines(mdx.toPath()).count();
// if (a != m) fail("line count mismatch: " + a + " vs " + m); Prevention
- When porting a spec, copy the file verbatim first then edit in place to preserve line structure.
- Diff the two files as part of your migration review.
- Avoid reformatting (line-wrapping) one side independently of the other.
When it happens
Trigger: Both `<name>.asciidoc.yml` and `<name>.mdx.yml` exist but their line counts differ. Typically happens when hand-porting a spec and missing or duplicating a request/response line.
Common situations: A merge conflict resolved by taking one side's line count; a copy-paste that duplicated a stanza; a find/replace that collapsed two lines into one or vice-versa.
Related errors
- Couldn't find the corresponding mdx file for {asciidocFileAb
- Yaml rest specs ({asciidocFile} and {mdxFile}) are not equal
- Unexpected unconverted snippets: {foundButNotListed}
- {name}: Snippet missing a language. This is required by Elas
- {name}: No need for NOTCONSOLE if snippet doesn't contain `c
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/87706ce16e477cf1.
Report an issue: GitHub.