Skip to content

Commit

Permalink
Release Java SDK v16.6.6 (#669)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
idimov-keeper authored Nov 26, 2024
1 parent fab6c47 commit e12230c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
3 changes: 3 additions & 0 deletions sdk/java/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sdk/java/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -480,7 +480,7 @@ fun getNotationResults(options: SecretsManagerOptions, notation: String): List<S
val selector = parsedNotation[2].text?.first ?: // type|title|notes or file|field|custom_field
throw Exception("Invalid notation '$notation'")
val recordToken = parsedNotation[1].text?.first ?: // UID or Title
throw Exception("Invalid notation $'notation'")
throw Exception("Invalid notation '$notation'")

// to minimize traffic - if it looks like a Record UID try to pull a single record
var records = listOf<KeeperRecord>()
Expand Down Expand Up @@ -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 [email protected]")
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 [email protected] for assistance.")
//println(e.message)
recordData = nonStrictJson.decodeFromString<KeeperRecordData>(bytesToString(decryptedRecord))
try {
// Attempt to parse the record data with unknown fields
recordData = nonStrictJson.decodeFromString<KeeperRecordData>(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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit e12230c

Please sign in to comment.