{"record":{"id":"f613b9a748ad05e1","repo":"elastic/elasticsearch","slug":"expected-line-line-1-in-path-to-be","errorCode":null,"errorMessage":"expected line [${line + 1}] in [${path}] to be [${expectedLine}] but was [${actualLine}]","messagePattern":"expected line \\[(.+?)\\] in \\[(.+?)\\] to be \\[(.+?)\\] but was \\[(.+?)\\]","errorType":"validation","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveCheckPlugin.java","lineNumber":200,"sourceCode":"            if (project.getName().contains(\"tar\")) {\n                t.from(archiveOperations.tarTree(distTaskOutput(buildDistTask)));\n            } else {\n                t.from(archiveOperations.zipTree(distTaskOutput(buildDistTask)));\n            }\n            t.into(archiveExtractionDir);\n            // common sanity checks on extracted archive directly as part of checkExtraction\n            t.eachFile(fileCopyDetails -> assertNoClassFile(fileCopyDetails.getFile()));\n        });\n    }\n\n    private static void assertLinesInFile(Path path, List<String> expectedLines) {\n        try {\n            final List<String> actualLines = Files.readAllLines(path);\n            int line = 0;\n            for (final String expectedLine : expectedLines) {\n                final String actualLine = actualLines.get(line);\n                if (expectedLine.equals(actualLine) == false) {\n                    throw new GradleException(\n                        \"expected line [\" + (line + 1) + \"] in [\" + path + \"] to be [\" + expectedLine + \"] but was [\" + actualLine + \"]\"\n                    );\n                }\n                line++;\n            }\n        } catch (IOException ioException) {\n            throw new GradleException(\"Unable to read from file \" + path, ioException);\n        }\n    }\n\n    private static void assertNoClassFile(File file) {\n        if (file.getName().endsWith(\".class\")) {\n            throw new GradleException(\"Detected class file in distribution ('\" + file.getName() + \"')\");\n        }\n    }\n\n    private Object distTaskOutput(TaskProvider<Task> buildDistTask) {\n        return new Callable<File>() {","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveCheckPlugin.java#L182-L218","documentation":"Thrown as GradleException by assertLinesInFile() when a line in the file at a given position doesn't exactly equal the expected line. Unlike the NOTICE 'contains' check, this asserts ordered, line-by-line equality starting from line 1 — used for NOTICE.txt header ('Elasticsearch', 'Copyright 2009-2024 Elasticsearch') and LICENSE.txt content where exact prefix ordering matters.","triggerScenarios":"assertLinesInFile (line 193) reads all lines, then iterates expectedLines comparing actualLines.get(line) with expectedLine. The first mismatch throws with 1-based line number, path, expected, and actual. Called from checkNotice (NOTICE.txt header) and checkLicense (LICENSE.txt full content).","commonSituations":"Copyright year bumped (e.g., 2024 → 2025) but the expected line wasn't updated; license file regenerated with different whitespace or line endings; a new top-of-file line shifted all subsequent lines; LICENSE.txt template changed upstream.","solutions":["Read the error's expected vs actual strings — usually a year, version, or whitespace difference.","Update the expected lines in registerCheckNoticeTask (the 'Elasticsearch' / copyright line) or the source LICENSE.txt template to match actual content.","Regenerate the license file from source with the licensing plugin before running check.","Ensure line endings are consistent (LF) — Files.readAllLines uses UTF-8 and splits on LF/CRLF, but mixed endings can shift content."],"exampleFix":"// before: hardcoded copyright year is stale\nfinal List<String> noticeLines = Arrays.asList(\"Elasticsearch\", \"Copyright 2009-2024 Elasticsearch\");\n\n// after: keep the year in sync with the build\nfinal List<String> noticeLines = Arrays.asList(\"Elasticsearch\", \"Copyright 2009-\" + Year.now() + \" Elasticsearch\");","handlingStrategy":"validation","validationCode":"List<String> actual = Files.readAllLines(path);\nif (actual.size() < expectedLines.size()\n    || IntStream.range(0, expectedLines.size())\n        .anyMatch(i -> expectedLines.get(i).equals(actual.get(i)) == false)) {\n    System.err.println(\"Line mismatch in \" + path);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Update expected notice/license lines when copyright years or license text change.","Keep LICENSE.txt source template and expected lines in sync.","Use a single source of truth for the copyright year (e.g., a build property).","Verify line endings (LF) before running checks on Windows."],"tags":["distribution","licensing","notice","validation"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}