Skip to content

[BUG] NullPointerException in BioServiceImpl.getSDKScore() when SDK omits modality key from quality score map #789

Description

@ayuxsh009

Short Summary of the Bug

SDK's getModalityQuality() may return no entry for the queried BiometricType; auto-unboxing causes NPE

Description

Summary

getSDKScore() auto-unboxes the Float returned by scoreMap.get(biometricType) directly to double.

If the SDK's getModalityQuality() does not populate an entry for the queried BiometricType,
get() returns null and the unboxing throws an unchecked NullPointerException.

Affected File

registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java

Code

Map<BiometricType, Float> scoreMap = bioAPIFactory
        .getBioProvider(biometricType, BiometricFunction.QUALITY_CHECK)
        .getModalityQuality(birList, null);

return scoreMap.get(biometricType); // NPE if key absent — Float null unboxed to double

Impact

The NPE is not a BiometricException, so it escapes the catch block at line ~104 and
falls into the generic catch (Throwable t) at line ~114, where it gets re-thrown as
MDS_RCAPTURE_ERROR — misclassifying an SDK quality check failure as an MDM capture failure.

This makes root cause diagnosis significantly harder.

Steps to Reproduce

  1. Configure mosip.registration.quality_check_with_sdk=Enable
  2. Use an SDK implementation whose getModalityQuality() returns a map without an entry
    for the captured modality (e.g., IRIS when only FINGER is keyed)
  3. Attempt biometric capture — registration client throws MDS_RCAPTURE_ERROR
    with no MDM involvement

Expected Behavior

A null-safe check with a descriptive BiometricException:

Float score = scoreMap.get(biometricType);

if (score == null) {
    throw new BiometricException(
        "SDK_SCORE_NULL",
        "SDK did not return quality score for " + biometricType
    );
}

return score.doubleValue();

Attachments / Evidence / Links

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions