{"record":{"id":"b0701df0e4c92c0d","repo":"quarkusio/quarkus","slug":"unable-to-read-file-f","errorCode":null,"errorMessage":"Unable to read file '\" + f + \"'","messagePattern":"Unable to read file '\" \\+ f \\+ \"'","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/kubernetes-service-binding/runtime/src/main/java/io/quarkus/kubernetes/service/binding/runtime/ServiceBinding.java","lineNumber":89,"sourceCode":"        File[] files = directory.toFile().listFiles(new FileFilter() {\n            @Override\n            public boolean accept(File f) {\n                try {\n                    return !Files.isHidden(f.toPath()) && !Files.isDirectory(f.toPath());\n                } catch (IOException e) {\n                    throw new IllegalStateException(\"Unable to determine if file '\" + f + \"' is a regular file\", e);\n                }\n            }\n        });\n\n        Map<String, String> result = new HashMap<>();\n        if (files != null) {\n            for (File f : files) {\n                try {\n                    result.put(f.toPath().getFileName().toString(),\n                            Files.readString(f.toPath()).trim());\n                } catch (IOException e) {\n                    throw new IllegalStateException(\"Unable to read file '\" + f + \"'\", e);\n                }\n            }\n        }\n        return result;\n    }\n\n    public String getName() {\n        return name;\n    }\n\n    public Map<String, String> getProperties() {\n        return properties;\n    }\n\n    public String getType() {\n        return type;\n    }\n","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/kubernetes-service-binding/runtime/src/main/java/io/quarkus/kubernetes/service/binding/runtime/ServiceBinding.java#L71-L107","documentation":"ServiceBinding.getFilenameToContentMap reads every regular file in a binding directory with Files.readString and wraps any IOException in IllegalStateException('Unable to read file X'). One unreadable file (wrong permissions, unreadable encoding, or vanishing mid-read) aborts construction of the whole binding.","triggerScenarios":"A file in the binding directory exists and passes the accept filter, but Files.readString fails — no read permission, I/O error on a mounted volume, or the file is deleted/replaced between listing and read.","commonSituations":"Credentials files mounted with restrictive permissions the app user can't read; partially mounted secret volumes; binary or non-UTF8 files in the binding directory breaking readString; container user mismatch (root-created files, non-root app).","solutions":["Check and fix read permissions on the file named in the message (chmod/ownership).","Ensure the secret volume is fully mounted and the file exists at read time.","Remove non-text/binary files from the binding directory — every regular file is read as a string.","Run the container as the user that owns the mounted files, or relax the mount's defaultMode.","Check the wrapped IOException cause for the precise OS error."],"exampleFix":"# before: mounted secret unreadable by app user\ndefaultMode: 0600  # app runs as uid 1001\n# after\ndefaultMode: 0444\n# or chown 1001 the files / run container as matching uid","handlingStrategy":"validation","validationCode":"static void assertAllFilesReadable(Path dir) throws IOException {\n    try (var s = Files.list(dir)) {\n        s.filter(Files::isRegularFile)\n         .forEach(f -> {\n             if (!Files.isReadable(f)) throw new IllegalStateException(\"Unreadable binding file: \" + f);\n             if (!f.getFileName().toString().equals(\"type\") && isBinary(f)) {\n                 throw new IllegalStateException(\"Non-text file in binding dir: \" + f);\n             }\n         });\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    loadBindings();\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"Unable to read file\")) {\n        log.error(\"Binding file unreadable: {} — fix permissions/mount\", e.getMessage());\n    }\n}","preventionTips":["Set secret volume defaultMode to 0444 (or chown files to the app UID).","Keep the binding directory text-only: every regular file is read as UTF-8.","Verify mount completeness (all expected keys present) right after container start.","Match container runAsUser with the secret volume's owning UID."],"tags":["service-binding","filesystem","io","permissions","secrets"],"backgroundTag":"filesystem-io-error","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}