{"record":{"id":"ea3eed8c11c29081","repo":"SonarSource/sonarqube","slug":"branch-export-failed-after-processing-d-branch-es","errorCode":null,"errorMessage":"Branch export failed after processing %d branch(es) successfully","messagePattern":"Branch export failed after processing (.+?) branch\\(es\\) successfully","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStep.java","lineNumber":73,"sourceCode":"        ProjectDump.Branch.Builder builder = ProjectDump.Branch.newBuilder();\n        List<BranchDto> branches = dbClient.projectExportDao()\n          .selectBranchesForExport(dbSession, projectHolder.projectDto().getUuid());\n        for (BranchDto branch : branches) {\n          builder\n            .clear()\n            .setUuid(branch.getUuid())\n            .setProjectUuid(branch.getProjectUuid())\n            .setKee(branch.getKey())\n            .setIsMain(branch.isMain())\n            .setBranchType(branch.getBranchType().name())\n            .setMergeBranchUuid(defaultString(branch.getMergeBranchUuid()));\n          output.write(builder.build());\n          ++count;\n        }\n        LoggerFactory.getLogger(getClass()).debug(\"{} branches exported\", count);\n      }\n    } catch (Exception e) {\n      throw new IllegalStateException(format(\"Branch export failed after processing %d branch(es) successfully\", count), e);\n    }\n  }\n\n  @Override\n  public String getDescription() {\n    return \"Export branches\";\n  }\n}\n","sourceCodeStart":55,"sourceCodeEnd":82,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStep.java#L55-L82","documentation":"ExportBranchesStep.execute() streams all branches of the project into the dump. Any exception while iterating or writing branch protobufs is wrapped in an IllegalStateException reporting how many branches were exported successfully before the failure.","triggerScenarios":"SQLException scrolling the branch select; BranchDto-to-protobuf conversion failure; output.write() IO error; a branch referencing missing entities (e.g. merge branch uuid not found).","commonSituations":"Corrupt branch data after manual DB edits; branches referencing deleted analysis or components; DB connectivity loss during a long export.","solutions":["Look at the wrapped cause to find the real error (SQL vs protobuf vs IO) and address it.","Verify branch rows are consistent: target/merge branch uuids and uuid paths point to existing entities.","Check DB connectivity and retry the export CE task.","If a single corrupt branch row is the cause, fix or delete it after backing up."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-check branch referential integrity before export\nSELECT b.uuid FROM branches b LEFT JOIN branches t ON b.merge_branch_uuid = t.uuid WHERE b.merge_branch_uuid IS NOT NULL AND t.uuid IS NULL;","typeGuard":null,"tryCatchPattern":"try {\n  exportBranchesStep.execute(context);\n} catch (IllegalStateException e) {\n  logger.error(\"Branch export failed at branch #{}: {}\", parseCount(e.getMessage()), e.getCause(), e);\n  throw new JobFailure(e.getCause());\n}","preventionTips":["Avoid manual edits to the BRANCHES table","Verify merge/target branch references point to existing branches","Check DB connectivity for large projects before starting export","Always diagnose via e.getCause()"],"tags":["export","branches","database","sonarqube"],"backgroundTag":"database-query-failed","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}