{"record":{"id":"480fc1448e9163b3","repo":"elastic/elasticsearch","slug":"unable-to-read-the-file-attributes","errorCode":null,"errorMessage":"unable to read the file {} attributes","messagePattern":"unable to read the file (.+?) attributes","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/FilePermissionsTask.java","lineNumber":75,"sourceCode":"    private File outputMarker;\n\n    @Inject\n    public FilePermissionsTask(ProjectLayout projectLayout) {\n        this.projectLayout = projectLayout;\n        this.outputMarker = new File(projectLayout.getBuildDirectory().getAsFile().get(), \"markers/filePermissions\");\n        setDescription(\"Checks java source files for correct file permissions\");\n    }\n\n    private static boolean isExecutableFile(File file) {\n        try {\n            Set<PosixFilePermission> permissions = Files.getFileAttributeView(file.toPath(), PosixFileAttributeView.class)\n                .readAttributes()\n                .permissions();\n            return permissions.contains(PosixFilePermission.OTHERS_EXECUTE)\n                || permissions.contains(PosixFilePermission.OWNER_EXECUTE)\n                || permissions.contains(PosixFilePermission.GROUP_EXECUTE);\n        } catch (IOException e) {\n            throw new IllegalStateException(\"unable to read the file \" + file + \" attributes\", e);\n        }\n    }\n\n    /**\n     * Returns the files this task will check\n     */\n    @InputFiles\n    @IgnoreEmptyDirectories\n    @SkipWhenEmpty\n    @PathSensitive(PathSensitivity.RELATIVE)\n    public FileCollection getFiles() {\n        return getSources().get()\n            .stream()\n            .map(sourceTree -> sourceTree.matching(filesFilter))\n            .reduce(FileTree::plus)\n            .orElse(projectLayout.files().getAsFileTree());\n    }\n","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/FilePermissionsTask.java#L57-L93","documentation":"Thrown by FilePermissionsTask.isExecutableFile when Files.getFileAttributeView(...).readAttributes() raises an IOException — the task could not read POSIX permissions of a file it was asked to audit. Because the whole point of the task is to inspect permissions, an unreadable file is a hard failure rather than a skip.","triggerScenarios":"A source file in getFiles() whose POSIX attribute view cannot be read: the file vanished between configuration and execution, the filesystem does not support POSIX views, or an I/O error occurred.","commonSituations":"A source file deleted or moved concurrently with the task run; running on a non-POSIX filesystem mounted in a way that breaks PosixFileAttributeView; transient I/O errors on network-mounted source trees.","solutions":["Inspect the wrapped IOException and the cited file path; confirm the file still exists.","If files are being generated/deleted during the build, ensure this task runs at a stable point (after sources settle).","On exotic filesystems, run the build on a local POSIX volume.","Re-run after a clean checkout to rule out a half-written file."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Skip files that no longer exist before delegating to isExecutableFile\nList<File> existing = files.stream().filter(File::isFile).collect(Collectors.toList());","typeGuard":null,"tryCatchPattern":"try {\n    boolean exec = isExecutableFile(file);\n} catch (IllegalStateException e) {\n    if (file.exists()) throw e;            // genuine IO problem -> escalate\n    // file vanished mid-build: skip with a warning rather than fail\n}","preventionTips":["Keep source sets stable while precommit tasks run (declare proper task dependencies).","Run on a local POSIX filesystem; avoid exotic mounts for the source tree.","Use a clean checkout if transient file issues appear."],"tags":["gradle","file-permissions","precommit","posix","io"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}