Skip to content

Commit da62879

Browse files
authored
Merge pull request eu-digital-identity-wallet#513 from niscy-eudiw/bugfix/fix_null_claim_value
Bugfix: Add null-safety for claim values
2 parents ed4819b + d11e744 commit da62879

File tree

2 files changed

+43
-35
lines changed

2 files changed

+43
-35
lines changed

common-feature/src/main/java/eu/europa/ec/commonfeature/util/DocumentHelper.kt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -370,17 +370,21 @@ private fun insertPath(
370370
return if (path.value.size == 1) {
371371
// Leaf node (Primitive or Nested Structure)
372372
if (existingNode == null && currentClaim != null) {
373-
val accumulatedClaims: MutableList<ClaimDomain> = mutableListOf()
374-
createKeyValue(
375-
item = currentClaim.value!!,
376-
groupKey = currentClaim.identifier,
377-
resourceProvider = resourceProvider,
378-
uuidProvider = uuidProvider,
379-
claimMetaData = currentClaim.issuerMetadata,
380-
disclosurePath = disclosurePath,
381-
allItems = accumulatedClaims,
382-
)
383-
tree + accumulatedClaims
373+
currentClaim.value?.let { safeClaimValue ->
374+
val accumulatedClaims: MutableList<ClaimDomain> = mutableListOf()
375+
376+
createKeyValue(
377+
item = safeClaimValue,
378+
groupKey = currentClaim.identifier,
379+
resourceProvider = resourceProvider,
380+
uuidProvider = uuidProvider,
381+
claimMetaData = currentClaim.issuerMetadata,
382+
disclosurePath = disclosurePath,
383+
allItems = accumulatedClaims,
384+
)
385+
386+
tree + accumulatedClaims
387+
} ?: tree // No value to add (claim value is null), return unchanged
384388
} else {
385389
tree // Already exists or not available, return unchanged
386390
}

dashboard-feature/src/main/java/eu/europa/ec/dashboardfeature/interactor/TransactionDetailsInteractor.kt

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -193,33 +193,37 @@ class TransactionDetailsInteractorImpl(
193193
val domainClaims: MutableList<ClaimDomain> = mutableListOf()
194194

195195
presentedDocument.claims.forEach { presentedClaim ->
196-
val elementIdentifier = when (presentedDocument.format) {
197-
is MsoMdocFormat -> presentedClaim.path.last()
198-
is SdJwtVcFormat -> presentedClaim.path.joinToString(".")
199-
}
196+
presentedClaim.value?.let { safePresentedClaimValue ->
200197

201-
val claimType = when (presentedDocument.format) {
202-
is MsoMdocFormat -> ClaimType.MsoMdoc(
203-
namespace = presentedClaim.path.first()
204-
)
198+
val elementIdentifier = when (presentedDocument.format) {
199+
is MsoMdocFormat -> presentedClaim.path.last()
200+
is SdJwtVcFormat -> presentedClaim.path.joinToString(".")
201+
}
205202

206-
is SdJwtVcFormat -> ClaimType.SdJwtVc
207-
}
203+
val claimType = when (presentedDocument.format) {
204+
is MsoMdocFormat -> ClaimType.MsoMdoc(
205+
namespace = presentedClaim.path.first()
206+
)
208207

209-
val itemPath = when (presentedDocument.format) {
210-
is MsoMdocFormat -> listOf(elementIdentifier)
211-
is SdJwtVcFormat -> presentedClaim.path
212-
}.toClaimPathDomain(type = claimType)
213-
214-
createKeyValue(
215-
item = presentedClaim.value!!,
216-
groupKey = elementIdentifier,
217-
disclosurePath = itemPath,
218-
resourceProvider = resourceProvider,
219-
claimMetaData = presentedClaim.metadata,
220-
allItems = domainClaims,
221-
uuidProvider = uuidProvider
222-
)
208+
is SdJwtVcFormat -> ClaimType.SdJwtVc
209+
}
210+
211+
val itemPath = when (presentedDocument.format) {
212+
is MsoMdocFormat -> listOf(elementIdentifier)
213+
is SdJwtVcFormat -> presentedClaim.path
214+
}.toClaimPathDomain(type = claimType)
215+
216+
217+
createKeyValue(
218+
item = safePresentedClaimValue,
219+
groupKey = elementIdentifier,
220+
disclosurePath = itemPath,
221+
resourceProvider = resourceProvider,
222+
claimMetaData = presentedClaim.metadata,
223+
allItems = domainClaims,
224+
uuidProvider = uuidProvider
225+
)
226+
}
223227
}
224228

225229
val uniqueId = itemIdentifierPrefix + index

0 commit comments

Comments
 (0)