From 9d3c40d574627341d777f4eb50072f227493d91c Mon Sep 17 00:00:00 2001 From: AssahBismarkabah Date: Wed, 6 Nov 2024 15:36:40 +0100 Subject: [PATCH 1/2] improved logging for realm retrieval errors --- CHANGELOG.md | 2 ++ .../keycloak/config/service/checksum/ChecksumService.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62985bc76..01b306fc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- improved logging for realm retrieval errors [#1010](https://github.com/adorsys/keycloak-config-cli/issues/1010) ### Fixed - Allow environment variables from existing secrets [#822](https://github.com/adorsys/keycloak-config-cli/issues/822) ### Fixed diff --git a/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java b/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java index 735e4b14d..92f6956f8 100644 --- a/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java +++ b/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java @@ -52,6 +52,9 @@ public ChecksumService(RealmRepository realmRepository, ImportConfigProperties i public void doImport(RealmImport realmImport) { RealmRepresentation existingRealm = realmRepository.get(realmImport.getRealm()); + if (existingRealm == null) { + throw new InvalidImportException("The specified realm does not exist: " + realmImport.getRealm()); + } Map customAttributes = existingRealm.getAttributes(); String importChecksum = realmImport.getChecksum(); From 738c4cbab3a34043b70df4ba23f0662a41dfe97a Mon Sep 17 00:00:00 2001 From: AssahBismarkabah Date: Wed, 6 Nov 2024 16:17:44 +0100 Subject: [PATCH 2/2] fix test failures in workflow --- .../keycloak/config/service/checksum/ChecksumService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java b/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java index 92f6956f8..87bd7b21a 100644 --- a/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java +++ b/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java @@ -52,9 +52,6 @@ public ChecksumService(RealmRepository realmRepository, ImportConfigProperties i public void doImport(RealmImport realmImport) { RealmRepresentation existingRealm = realmRepository.get(realmImport.getRealm()); - if (existingRealm == null) { - throw new InvalidImportException("The specified realm does not exist: " + realmImport.getRealm()); - } Map customAttributes = existingRealm.getAttributes(); String importChecksum = realmImport.getChecksum(); @@ -67,6 +64,9 @@ public void doImport(RealmImport realmImport) { public boolean hasToBeUpdated(RealmImport realmImport) { RealmRepresentation existingRealm = realmRepository.get(realmImport.getRealm()); + if (existingRealm == null) { + throw new InvalidImportException("The specified realm does not exist: " + realmImport.getRealm()); + } Map customAttributes = existingRealm.getAttributes(); String readChecksum = customAttributes.get(getCustomAttributeKey(realmImport));