elastic/elasticsearch · error · UncheckedIOException
Failed to read branches.json from {path}
Error message
Failed to read branches.json from {path} What it means
Wrapped as UncheckedIOException from UpdateBranchesJsonTask.readBranches() when branches.json exists but Files.readAllBytes or branchesFileParser.parse throws IOException — most commonly a malformed JSON file.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/UpdateBranchesJsonTask.java:173
updatedBranches.add(objectNode);
}
((ObjectNode) jsonNode).replace("branches", updatedBranches);
DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
prettyPrinter.indentArraysWith(new DefaultIndenter(" ", DefaultIndenter.SYS_LF));
objectMapper.writer(prettyPrinter).writeValue(branchesFile, jsonNode);
}
private List<DevelopmentBranch> readBranches(File branchesFile) {
if (branchesFile.isFile() == false) {
throw new InvalidUserDataException("File branches.json has not been found in " + branchesFile.getAbsolutePath());
}
try {
byte[] branchesBytes = Files.readAllBytes(branchesFile.toPath());
return branchesFileParser.parse(branchesBytes);
} catch (IOException e) {
throw new UncheckedIOException("Failed to read branches.json from " + branchesFile.getPath(), e);
}
}
}
View on GitHub (pinned to db6a809a66)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
// Smoke-test that branches.json parses before invoking the task
try {
new ObjectMapper().readTree(branchesFile);
} catch (IOException e) {
throw new GradleException("branches.json is not valid JSON: " + e.getMessage(), e);
} Try / catch
try { task.executeTask(); } catch (UncheckedIOException e) { log.error("branches.json unreadable at {}: {}", branchesFile, e.getMessage()); throw e; } Prevention
- Lint branches.json in CI on every commit.
- Resolve merge conflicts in branches.json before running the task.
When it happens
Trigger: branches.json is present but is not valid JSON, or does not conform to the shape expected by branchesFileParser (array of {branch, version} objects).
Common situations: A manual edit broke the JSON; a merge conflict left conflict markers in the file; an earlier failed write truncated it.
Related errors
- Incorrect format for line [%s]
- Release [%s] already recorded with version id [%s], cannot u
- Branch {branch} already exists
- Branch {branch} does not exist
- File branches.json has not been found in {path}
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/26ea95958bf6bcbb.
Report an issue: GitHub.