{"record":{"id":"87706ce16e477cf1","repo":"elastic/elasticsearch","slug":"yaml-rest-specs-asciidocfile-and-mdxfile-are","errorCode":null,"errorMessage":"Yaml rest specs ({asciidocFile} and {mdxFile}) are not equal, different line count","messagePattern":"Yaml rest specs \\((.+?) and (.+?)\\) are not equal, different line count","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/doc/RestTestsFromDocSnippetTask.java","lineNumber":525,"sourceCode":"        public void finishLastTest() {\n            if (current != null) {\n                current.close();\n                current = null;\n            }\n        }\n    }\n\n    private void assertEqualTestSnippetFromMigratedDocs() {\n        getTestRoot().getAsFileTree().matching(patternSet -> { patternSet.include(\"**/*asciidoc.yml\"); }).forEach(asciidocFile -> {\n            File mdxFile = new File(asciidocFile.getAbsolutePath().replace(\".asciidoc.yml\", \".mdx.yml\"));\n            if (mdxFile.exists() == false) {\n                throw new InvalidUserDataException(\"Couldn't find the corresponding mdx file for \" + asciidocFile.getAbsolutePath());\n            }\n            try {\n                List<String> asciidocLines = Files.readAllLines(asciidocFile.toPath());\n                List<String> mdxLines = Files.readAllLines(mdxFile.toPath());\n                if (asciidocLines.size() != mdxLines.size()) {\n                    throw new GradleException(\n                        \"Yaml rest specs (\"\n                            + asciidocFile.toPath()\n                            + \" and \"\n                            + mdxFile.getAbsolutePath()\n                            + \") are not equal, different line count\"\n                    );\n\n                }\n                for (int i = 0; i < asciidocLines.size(); i++) {\n                    if (asciidocLines.get(i)\n                        .replaceAll(\"line_\\\\d+\", \"line_0\")\n                        .equals(mdxLines.get(i).replaceAll(\"line_\\\\d+\", \"line_0\")) == false) {\n                        throw new GradleException(\n                            \"Yaml rest specs (\"\n                                + asciidocFile.toPath()\n                                + \" and \"\n                                + mdxFile.getAbsolutePath()\n                                + \") are not equal, difference on line: \"","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/doc/RestTestsFromDocSnippetTask.java#L507-L543","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before: asciidoc.yml has 12 lines, mdx.yml has 11\n# after: add the missing line to mdx.yml so both have 12","handlingStrategy":"validation","validationCode":"// Before building, assert line counts match:\n// long a = Files.lines(asciidoc.toPath()).count();\n// long m = Files.lines(mdx.toPath()).count();\n// if (a != m) fail(\"line count mismatch: \" + a + \" vs \" + m);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["docs","snippet-tests","mdx-migration","build","validation"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}