{"record":{"id":"551b5c1bfecc0e50","repo":"elastic/elasticsearch","slug":"failed-to-fetch-branch-normalizedbranch-from-so","errorCode":null,"errorMessage":"Failed to fetch branch {normalizedBranch} from {sourceRepo} for external changelogs","messagePattern":"Failed to fetch branch (.+?) from (.+?) for external changelogs","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/BundleChangelogsTask.java","lineNumber":293,"sourceCode":"            return List.of();\n        }\n        String normalizedBranch = normalizeBranchForExternalFetch(branchRef, esUpstreamRemote);\n\n        try {\n            if (bcRefForFilter != null && bcRefForFilter.isBlank() == false) {\n                // Full history: shallow fetch can hide PR merges older than --depth from FETCH_HEAD,\n                // causing BC grep filtering to drop valid external changelog entries.\n                LOGGER.info(\n                    \"Fetching full history from {}:{} for BC filtering (may be slower than shallow fetch)\",\n                    source.sourceRepo(),\n                    normalizedBranch\n                );\n                gitWrapper.runCommand(\"git\", \"fetch\", source.repoUrl(), normalizedBranch);\n            } else {\n                gitWrapper.runCommand(\"git\", \"fetch\", \"--depth=1\", source.repoUrl(), normalizedBranch);\n            }\n        } catch (Exception e) {\n            throw new GradleException(\n                \"Failed to fetch branch \" + normalizedBranch + \" from \" + source.sourceRepo() + \" for external changelogs\",\n                e\n            );\n        }\n\n        String externalHead = gitWrapper.runCommand(\"git\", \"rev-parse\", \"FETCH_HEAD\").trim();\n\n        String treePath = source.changelogPath();\n\n        List<String> files;\n        try {\n            files = gitWrapper.listFiles(\"FETCH_HEAD\", treePath).filter(f -> f.endsWith(\".yaml\")).toList();\n        } catch (Exception e) {\n            LOGGER.warn(\"No changelog directory found at {} in {}:{}\", treePath, source.sourceRepo(), normalizedBranch);\n            return List.of();\n        }\n\n        if (files.isEmpty()) {","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/BundleChangelogsTask.java#L275-L311","documentation":"Thrown by BundleChangelogsTask when fetching an external changelog source (a separate repo) fails. The task runs `git fetch [--depth=1] <repoUrl> <branch>` inside a try; any Exception (network error, ref-not-found, auth) is caught and rethrown as a GradleException naming the normalized branch and source repo so the developer knows which external source failed.","triggerScenarios":"An external changelog source configured in the bundling spec specifies a repoUrl and branch; the git fetch for that source fails — wrong branch name, no network, missing permissions, or the ref doesn't exist on the remote. The catch wraps the original exception.","commonSituations":"Typo in the external branch name; the external repo/branch was renamed or deleted; network/firewall blocking the fetch; SSH/HTTPS credentials not configured for the external remote; running offline.","solutions":["Verify the external branch name exists on the configured sourceRepo (normalizeBranchForExternalFetch strips known prefixes — pass a plain branch name).","Confirm network access and git credentials for the external repoUrl (try `git ls-remote <repoUrl>` manually).","If running offline, fetch the external sources beforehand or remove the external source from the bundling config for this run.","Re-run bundleChangelogs after correcting the branch/credentials."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Preflight: verify the external ref is fetchable\ntry {\n    gitRun(\"ls-remote\", sourceRepo.repoUrl(), normalizedBranch);\n} catch (Exception e) {\n    throw new IllegalStateException(\"External branch not reachable: \" + normalizedBranch, e);\n}","typeGuard":null,"tryCatchPattern":"try { fetchExternal(source); }\ncatch (GradleException e) {\n    // inspect cause: network vs missing ref vs auth; fix and retry, don't silently skip\n    throw e;\n}","preventionTips":["Verify external branch names and credentials before release runs.","Run `git ls-remote` preflight checks for each external source.","Ensure network access and SSH/HTTPS config on the build host."],"tags":["build","gradle","release","changelog","git","network"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}