{"record":{"id":"444a923dc1ae54c2","repo":"eclipse-vertx/vert.x","slug":"failed-to-read-path","errorCode":null,"errorMessage":"Failed to read ${path}","messagePattern":"Failed to read (.+?)","errorType":"exception","errorClass":"FileSystemException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java","lineNumber":867,"sourceCode":"  private BlockingAction<Buffer> readFileInternal(String path) {\n    Objects.requireNonNull(path);\n    return new BlockingAction<Buffer>() {\n      public Buffer perform() {\n        try {\n          Path target = resolveFile(path).toPath();\n          try (FileChannel fc = FileChannel.open(target, StandardOpenOption.READ)) {\n            long size = fc.size();\n            if (size > (long) Integer.MAX_VALUE) {\n              // Throwing OOM as Files#readAllLines would in this case\n              throw new OutOfMemoryError(\"File is too big\");\n            }\n            int len = (int) size;\n            BufferInternal res = BufferInternal.buffer(len);\n            res.unwrap().writeBytes(fc, 0, len);\n            return res;\n          }\n        } catch (IOException e) {\n          throw new FileSystemException(getFileAccessErrorMessage(\"read\", path), e);\n        }\n      }\n    };\n  }\n\n  private BlockingAction<Void> writeFileInternal(String path, Buffer data) {\n    Objects.requireNonNull(path);\n    Objects.requireNonNull(data);\n    return new BlockingAction<Void>() {\n      public Void perform() {\n        try {\n          Path target = resolveFile(path).toPath();\n          Files.write(target, data.getBytes());\n          return null;\n        } catch (IOException e) {\n          throw new FileSystemException(getFileAccessErrorMessage(\"write\", path), e);\n        }\n      }","sourceCodeStart":849,"sourceCodeEnd":885,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java#L849-L885","documentation":"Wrapped error in readFileInternal: opening the resolved path with FileChannel or reading its content threw an IOException. The message names the read operation and the raw path; the real reason (permission denied, file vanished, lock) is in the cause chain.","triggerScenarios":"Calling FileSystem.readFile(path) when the file does not exist, is a directory, permission is denied, or an I/O error occurs mid-read.","commonSituations":"Wrong working directory at runtime, file not packaged/deployed with the app, permission denied under a restricted service account, or reading a path that is actually a directory.","solutions":["Inspect the cause for the concrete I/O failure","Verify the file exists and is readable","Retry transient failures such as concurrent moves"],"exampleFix":"// before\nvertx.fileSystem().readFile(\"config.yaml\");\n// after\nvertx.fileSystem().exists(\"config.yaml\")\n  .onSuccess(exists -> { if (!exists) throw ...; })\n  .compose(v -> vertx.fileSystem().readFile(\"config.yaml\"));","handlingStrategy":"try-catch","validationCode":"if (!vertx.fileSystem().existsBlocking(path)) {\n  throw new IllegalArgumentException(\"File does not exist: \" + path);\n}","typeGuard":null,"tryCatchPattern":"try {\n  Buffer buf = fs.readFileBlocking(path);\n} catch (FileSystemException e) {\n  logger.error(\"Failed to read {}: {}\", path, e.getCause());\n  // handle missing file / permission error\n}","preventionTips":["Verify file existence and permissions before reading","Use paths relative to a verified working directory or classpath","Log and inspect the cause IOException to distinguish ENOENT vs EACCES"],"tags":["filesystem","io","read"],"backgroundTag":"file-read-failed","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}