{"record":{"id":"6a73a45c798f5bcb","repo":"elastic/elasticsearch","slug":"failed-to-read-branches-json-from","errorCode":null,"errorMessage":"Failed to read branches.json from: {}","messagePattern":"Failed to read branches\\.json from: (.+?)","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java","lineNumber":254,"sourceCode":"                        + \"]. Either disable offline mode, set -P\"\n                        + BRANCHES_FILE_LOCATION_PROPERTY\n                        + \"=<local file path>, or create branches.json at the workspace root.\"\n                );\n            }\n        }\n        LOGGER.info(\"Reading branches.json from {}\", branchesFileLocation);\n        byte[] branchesBytes;\n        if (isHttpLocation(branchesFileLocation)) {\n            try {\n                branchesBytes = HttpUtils.readHttpBytesWithRetry(branchesFileLocation);\n            } catch (IOException e) {\n                throw new UncheckedIOException(\"Failed to download branches.json from: \" + branchesFileLocation, e);\n            }\n        } else {\n            try {\n                branchesBytes = Files.readAllBytes(new File(branchesFileLocation).toPath());\n            } catch (IOException e) {\n                throw new UncheckedIOException(\"Failed to read branches.json from: \" + branchesFileLocation, e);\n            }\n        }\n\n        var branchesFileParser = new BranchesFileParser(new ObjectMapper());\n        return branchesFileParser.parse(branchesBytes);\n    }\n\n    private static boolean isHttpLocation(String branchesFileLocation) {\n        return branchesFileLocation.startsWith(\"http://\") || branchesFileLocation.startsWith(\"https://\");\n    }\n\n    private void logGlobalBuildInfo(BuildParameterExtension buildParams) {\n        final String osName = System.getProperty(\"os.name\");\n        final String osVersion = System.getProperty(\"os.version\");\n        final String osArch = System.getProperty(\"os.arch\");\n        final Jvm gradleJvm = Jvm.current();\n        JvmInstallationMetadata gradleJvmMetadata = metadataDetector.getMetadata(getJavaInstallation(gradleJvm.getJavaHome()));\n        final String gradleJvmVendorDetails = gradleJvmMetadata.getVendor().getDisplayName();","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java#L236-L272","documentation":"Thrown by GlobalBuildInfoPlugin.getDevelopmentBranches() when reading branches.json from a local file path fails. This path is taken when branchesFileLocation does not start with http:// or https:// (i.e., it is a local file path). Files.readAllBytes throws IOException, which is wrapped in UncheckedIOException.","triggerScenarios":"branchesFileLocation is a local path (set via -Pbranches.file.location=<path> or resolved from the offline-mode fallback to workspace-root/branches.json). The file exists (otherwise a different error may surface from the file-not-found IOException) but cannot be read, or the path is invalid. Files.readAllBytes throws IOException for permission denied, truncated file, or I/O errors.","commonSituations":"The user passes -Pbranches.file.location to a path that exists but is unreadable (permissions). The local branches.json at the workspace root is corrupted or partially written. A stale or broken symlink exists at the branches.json location.","solutions":["Verify the file path is correct and readable: test -r <path> && echo readable.","If the file is a symlink, ensure the target exists: readlink -f <path>.","Recreate the file from a known-good source.","Check file permissions: chmod +r <path> if the Gradle daemon process cannot read it."],"exampleFix":"# before\n./gradlew build -Pbranches.file.location=/home/user/branch.json  # typo: branch vs branches\n\n# after\n./gradlew build -Pbranches.file.location=/home/user/branches.json","handlingStrategy":"validation","validationCode":"// Validate local branches.json path before reading\nFile f = new File(branchesFileLocation);\nif (!f.exists()) {\n    throw new GradleException(\"branches.json not found at: \" + branchesFileLocation);\n}\nif (!f.canRead()) {\n    throw new GradleException(\"branches.json is not readable: \" + branchesFileLocation);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify file paths passed to branches.file.location are correct and readable.","Avoid typos in file names (branches.json vs branch.json).","Check symlink targets if branches.json is a symlink."],"tags":["filesystem","branches","io","configuration"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}