From e12230ce970ef1a5dfafe0023b6d38d09be2fcc5 Mon Sep 17 00:00:00 2001 From: idimov-keeper <78815270+idimov-keeper@users.noreply.github.com> Date: Tue, 26 Nov 2024 11:14:18 -0600 Subject: [PATCH] Release Java SDK v16.6.6 (#669) * Bump version to 16.6.6 * Improved nonStrictJson parser to be more lenient and allow nulls and trailing commas etc. * KSM-560 Improved error handling when parsing JSON (#668) * fixed a typo * Update SecretsManager.kt (#684) --- sdk/java/core/README.md | 3 +++ sdk/java/core/build.gradle.kts | 2 +- .../secretsManager/core/SecretsManager.kt | 25 +++++++++++++------ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/sdk/java/core/README.md b/sdk/java/core/README.md index 058bd672..bbfbb7cf 100644 --- a/sdk/java/core/README.md +++ b/sdk/java/core/README.md @@ -4,6 +4,9 @@ For more information see our official documentation page https://docs.keeper.io/ # Change Log +## 16.6.6 +- KSM-560 - Improved error handling when parsing JSON + ## 16.6.5 - KSM-548 - Make sure autogenerated UIDs don't start with '-' - KSM-553 - Added new field types and updated PAM field types diff --git a/sdk/java/core/build.gradle.kts b/sdk/java/core/build.gradle.kts index eff0e7c7..07eb250e 100644 --- a/sdk/java/core/build.gradle.kts +++ b/sdk/java/core/build.gradle.kts @@ -7,7 +7,7 @@ import java.util.* group = "com.keepersecurity.secrets-manager" // During publishing, If version ends with '-SNAPSHOT' then it will be published to Maven snapshot repository -version = "16.6.5" +version = "16.6.6" plugins { `java-library` diff --git a/sdk/java/core/src/main/kotlin/com/keepersecurity/secretsManager/core/SecretsManager.kt b/sdk/java/core/src/main/kotlin/com/keepersecurity/secretsManager/core/SecretsManager.kt index c92bf7bf..175b7442 100644 --- a/sdk/java/core/src/main/kotlin/com/keepersecurity/secretsManager/core/SecretsManager.kt +++ b/sdk/java/core/src/main/kotlin/com/keepersecurity/secretsManager/core/SecretsManager.kt @@ -17,7 +17,7 @@ import java.util.* import java.util.concurrent.* import javax.net.ssl.* -const val KEEPER_CLIENT_VERSION = "mj16.6.5" +const val KEEPER_CLIENT_VERSION = "mj16.6.6" const val KEY_HOSTNAME = "hostname" // base url for the Secrets Manager service const val KEY_SERVER_PUBIC_KEY_ID = "serverPublicKeyId" @@ -480,7 +480,7 @@ fun getNotationResults(options: SecretsManagerOptions, notation: String): List() @@ -809,11 +809,16 @@ private fun decryptRecord(record: SecretsManagerResponseRecord, recordKey: ByteA // New/missing field: Polymorphic serializer was not found for class discriminator 'UNKNOWN'... // New/missing field property (field def updated): Encountered unknown key 'UNKNOWN'. // Avoid 'ignoreUnknownKeys = true' to prevent erasing new properties on save/update - println("Record ${record.recordUid} has unexpected data properties (ignored).\n"+ - " Error parsing record type - KSM SDK is behind/ahead of record/field type definitions." + - " Please upgrade to latest version. If you need assistance please email support@keepersecurity.com") + println("Record ${record.recordUid} contains unrecognized data properties and could not be fully parsed.\n" + + "This may occur if the Keeper Secrets Manager (KSM) SDK version you're using is not compatible with the record's data schema.\n" + + "Please ensure that you are using the latest version of the KSM SDK. If the issue persists, contact support@keepersecurity.com for assistance.") //println(e.message) - recordData = nonStrictJson.decodeFromString(bytesToString(decryptedRecord)) + try { + // Attempt to parse the record data with unknown fields + recordData = nonStrictJson.decodeFromString(bytesToString(decryptedRecord)) + } catch (e: Exception) { + println("Error parsing record data with using non-strict JSON parser. Record ${record.recordUid} will be skipped.") + } } return if (recordData != null) KeeperRecord(recordKey, record.recordUid, null, null, record.innerFolderUid, recordData, record.revision, files) else null @@ -1075,7 +1080,13 @@ fun postFunction( return KeeperHttpResponse(statusCode, data) } -private val nonStrictJson = Json { ignoreUnknownKeys = true } +@ExperimentalSerializationApi +private val nonStrictJson = Json { + ignoreUnknownKeys = true + isLenient = true + coerceInputValues = true + allowTrailingComma = true +} var keyId = 7