{"record":{"id":"26ea95958bf6bcbb","repo":"elastic/elasticsearch","slug":"failed-to-read-branches-json-from-path","errorCode":null,"errorMessage":"Failed to read branches.json from {path}","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/release/UpdateBranchesJsonTask.java","lineNumber":173,"sourceCode":"            updatedBranches.add(objectNode);\n        }\n        ((ObjectNode) jsonNode).replace(\"branches\", updatedBranches);\n\n        DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();\n        prettyPrinter.indentArraysWith(new DefaultIndenter(\"  \", DefaultIndenter.SYS_LF));\n        objectMapper.writer(prettyPrinter).writeValue(branchesFile, jsonNode);\n    }\n\n    private List<DevelopmentBranch> readBranches(File branchesFile) {\n        if (branchesFile.isFile() == false) {\n            throw new InvalidUserDataException(\"File branches.json has not been found in \" + branchesFile.getAbsolutePath());\n        }\n\n        try {\n            byte[] branchesBytes = Files.readAllBytes(branchesFile.toPath());\n            return branchesFileParser.parse(branchesBytes);\n        } catch (IOException e) {\n            throw new UncheckedIOException(\"Failed to read branches.json from \" + branchesFile.getPath(), e);\n        }\n    }\n}\n","sourceCodeStart":155,"sourceCodeEnd":177,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/UpdateBranchesJsonTask.java#L155-L177","documentation":"Wrapped as UncheckedIOException from UpdateBranchesJsonTask.readBranches() when branches.json exists but Files.readAllBytes or branchesFileParser.parse throws IOException — most commonly a malformed JSON file.","triggerScenarios":"branches.json is present but is not valid JSON, or does not conform to the shape expected by branchesFileParser (array of {branch, version} objects).","commonSituations":"A manual edit broke the JSON; a merge conflict left conflict markers in the file; an earlier failed write truncated it.","solutions":["Validate branches.json with a JSON linter; fix any syntax errors or conflict markers.","Restore the last known-good version from git and re-apply intended changes atomically.","Ensure the file is an array of objects with branch (string) and version (string) fields."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Smoke-test that branches.json parses before invoking the task\ntry {\n    new ObjectMapper().readTree(branchesFile);\n} catch (IOException e) {\n    throw new GradleException(\"branches.json is not valid JSON: \" + e.getMessage(), e);\n}","typeGuard":null,"tryCatchPattern":"try { task.executeTask(); } catch (UncheckedIOException e) { log.error(\"branches.json unreadable at {}: {}\", branchesFile, e.getMessage()); throw e; }","preventionTips":["Lint branches.json in CI on every commit.","Resolve merge conflicts in branches.json before running the task."],"tags":["release-tooling","json","file-parsing","branches-json","data-integrity"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}