Source:
<code>public void startStackProvisioning(Long id, DetailedEnvironmentResponse environment) { sdxClusterRepository.findById(id).ifPresentOrElse(sdxCluster -> { LOGGER.info("Call cloudbreak with stackrequest"); try { stackRequestManifester.configureStackForSdxCluster(sdxCluster, environment); StackV4Request stackV4Request = JsonUtil.readValue(sdxCluster.getStackRequestToCloudbreak(), StackV4Request.class); Optional.ofNullable(sdxCluster.getDatabaseCrn()).ifPresent(crn -> { stackV4Request.getCluster().setDatabaseServerCrn(crn); sdxCluster.setStackRequestToCloudbreak(JsonUtil.writeValueAsStringSilent(stackV4Request)); }); StackV4Response stackV4Response; try { stackV4Response = stackV4Endpoint.get(0L, sdxCluster.getClusterName(), null); } catch (NotFoundException e) { LOGGER.info("Stack does not exist on cloudbreak side, POST new cluster: {}", sdxCluster.getClusterName(), e); stackV4Response = stackV4Endpoint.post(0L, stackV4Request); } sdxCluster.setStackId(stackV4Response.getId()); sdxCluster.setStackCrn(stackV4Response.getCrn()); sdxClusterRepository.save(sdxCluster); cloudbreakFlowService.saveLastCloudbreakFlowChainId(sdxCluster, stackV4Response.getFlowIdentifier()); LOGGER.info("Sdx cluster updated"); <START> } catch (ClientErrorException | InternalServerErrorException e) { <END> String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e); LOGGER.info("Can not start provisioning: {}", errorMessage, e); throw new RuntimeException("Can not start provisioning, client error happened on Cloudbreak side: " + errorMessage); } catch (IOException e) { LOGGER.info("Can not parse stackrequest to json", e); throw new RuntimeException("Can not write stackrequest to json: " + e.getMessage()); } }, () -> { throw notFound("SDX cluster", id).get(); }); }</code><technical_language>hmm.. throw badrequest instead of internal server error cloudbreak side</technical_language>

Target:
public void startStackProvisioning(Long id, DetailedEnvironmentResponse environment) { sdxClusterRepository.findById(id).ifPresentOrElse(sdxCluster -> { LOGGER.info("Call cloudbreak with stackrequest"); try { stackRequestManifester.configureStackForSdxCluster(sdxCluster, environment); StackV4Request stackV4Request = JsonUtil.readValue(sdxCluster.getStackRequestToCloudbreak(), StackV4Request.class); Optional.ofNullable(sdxCluster.getDatabaseCrn()).ifPresent(crn -> { stackV4Request.getCluster().setDatabaseServerCrn(crn); sdxCluster.setStackRequestToCloudbreak(JsonUtil.writeValueAsStringSilent(stackV4Request)); }); StackV4Response stackV4Response; try { stackV4Response = stackV4Endpoint.get(0L, sdxCluster.getClusterName(), null); } catch (NotFoundException e) { LOGGER.info("Stack does not exist on cloudbreak side, POST new cluster: {}", sdxCluster.getClusterName(), e); stackV4Response = stackV4Endpoint.post(0L, stackV4Request); } sdxCluster.setStackId(stackV4Response.getId()); sdxCluster.setStackCrn(stackV4Response.getCrn()); sdxClusterRepository.save(sdxCluster); cloudbreakFlowService.saveLastCloudbreakFlowChainId(sdxCluster, stackV4Response.getFlowIdentifier()); LOGGER.info("Sdx cluster updated"); } catch (WebApplicationException e) { String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e); LOGGER.info("Cannot start provisioning: {}", errorMessage, e); throw new RuntimeException("Cannot start provisioning, some error happened on Cloudbreak side: " + errorMessage); } catch (IOException e) { LOGGER.info("Cannot parse stackrequest to json", e); throw new RuntimeException("Cannot write stackrequest to json: " + e.getMessage()); } }, () -> { throw notFound("SDX cluster", id).get(); }); }