eu-digital-green-certificates/dgc-certlogic-android

[VH] Rules that fail with a (technical) exceptions should be reported as Open instead of propagating the exception

Closed this issue · 2 comments

Describe the bug

When a rule fails with a (technical) exception, the exception is populated to the caller:

return if (rules.isNotEmpty()) {
val validationResults = mutableListOf<ValidationResult>()
val dataJsonNode = prepareData(externalParameter, payload)
val hcertVersion = hcertVersionString.toVersion()
rules.forEach { rule ->
val ruleVersion = rule.version.toVersion()
val res = when {
hcertVersion == null || ruleVersion == null || hcertVersion.first != ruleVersion.first -> Result.OPEN
hcertVersion.isGreaterOrEqualThan(ruleVersion) &&
jsonLogicValidator.isDataValid(
rule.logic,
dataJsonNode
) -> Result.PASSED
else -> Result.FAIL
}
val cur: String = affectedFieldsDataRetriever.getAffectedFieldsData(
rule,
dataJsonNode,
certificateType
)
validationResults.add(
ValidationResult(
rule,
res,
cur,
null
)
)
}
validationResults
} else {
emptyList()
}

Expected behaviour

Any exceptions that might be thrown should be caught and mapped to open.

Steps to reproduce the issue

see code

Technical details

n/a

Possible Fix

try-catch statement + map to open

Additional context

n/a

LGTM, thanks for the fix!