{"record":{"id":"3985dee044b806bf","repo":"elastic/elasticsearch","slug":"unable-to-read-from-file-path","errorCode":null,"errorMessage":"Unable to read from file ${path}","messagePattern":"Unable to read from file (.+?)","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveCheckPlugin.java","lineNumber":207,"sourceCode":"            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>() {\n            @Override\n            public File call() {\n                return buildDistTask.get().getOutputs().getFiles().getSingleFile();\n            }\n\n            @Override\n            public String toString() {","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveCheckPlugin.java#L189-L225","documentation":"Thrown as GradleException by assertLinesInFile()'s catch(IOException) block when Files.readAllLines(path) fails for the file being checked. This is the I/O-failure counterpart to the line-mismatch error: the file exists (or doesn't) but cannot be read — missing file, permission denied, or encoding error.","triggerScenarios":"The try block at line 194 calls Files.readAllLines(path). If path doesn't exist, isn't readable, or contains malformed UTF-8, an IOException is thrown and wrapped at line 207. Typically fires when checkExtraction didn't extract the expected file (distribution build incomplete) or the path resolves incorrectly.","commonSituations":"The distribution archive was built incompletely (NOTICE.txt or LICENSE.txt missing from the archive); extraction directory was cleaned between build and check; path resolution bug in the noticePath/licensePathProvider mapping; file permissions on CI agent.","solutions":["Verify the file at the reported path actually exists after checkExtraction — re-run the distribution build if incomplete.","Check the path resolution logic in registerCheckNoticeTask/registerCheckLicenseTask for version-mismatch in 'elasticsearch-' + VersionProperties.getElasticsearch().","Ensure checkExtraction depends on the build task and ran successfully.","Inspect file permissions and encoding of the extracted file."],"exampleFix":"// before: path resolves to non-existent elasticsearch-9.0.0/NOTICE.txt\n// because VersionProperties.getElasticsearch() doesn't match archive name\n\n// after: confirm the version string matches the archive directory name\nString ver = VersionProperties.getElasticsearch();\nPath notice = extractionDir.resolve(\"elasticsearch-\" + ver + \"/NOTICE.txt\");\nif (Files.exists(notice) == false) {\n  throw new IllegalStateException(\"NOTICE.txt missing; archive dir mismatch: \" + notice);\n}","handlingStrategy":"validation","validationCode":"Path p = noticePath.get();\nif (Files.exists(p) == false) {\n    throw new IllegalStateException(\"File missing before check: \" + p);\n}\nif (Files.isReadable(p) == false) {\n    throw new IllegalStateException(\"File not readable: \" + p);\n}","typeGuard":null,"tryCatchPattern":"try {\n    assertLinesInFile(path, expectedLines);\n} catch (GradleException e) {\n    // includes IOException-wrapped message\n    throw e;\n}","preventionTips":["Ensure checkExtraction completes successfully before checkLicense/checkNotice run (dependsOn).","Verify the extracted archive contains NOTICE.txt and LICENSE.txt.","Confirm VersionProperties.getElasticsearch() matches the archive's directory name.","Run the full distribution build before the check tasks."],"tags":["distribution","io","licensing","gradle"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}