[MS-887] Fix Filtering Logic in CommCareIdentityDataSource #1113
Conversation
5973662 to
73ca9cf
Compare
| project: Project, | ||
| ): Boolean = when { | ||
| s1 == null -> false | ||
| s1 == null -> true // ignore null values as they are not tokenized |
There was a problem hiding this comment.
Doesn't this break the usual comparison/equals contract in kotlin? Usually, when nulls are involved, comparisons return false, as there is nothing to compare.
There was a problem hiding this comment.
Yes, you are right, I reverted it back to false.
| TokenKeyType.ModuleId, | ||
| project, | ||
| ) | ||
| isSubjectIdMatching(query, event) && |
There was a problem hiding this comment.
This line is very counter-intuitive since it reads as "filter items that match by all 3 fields".
I get the logic behind it, but the naming should be clearer, maybe at least something like "isNullOrMatching".
599a179 to
1796fb5
Compare
| }.orEmpty() | ||
| } | ||
|
|
||
| fun isSubjectIdNullOrMatching( |
There was a problem hiding this comment.
Do the functions need to be public?
…eationEvent` to resolve issues when either the module ID, attendant ID, or both are null.
1796fb5 to
6f77dba
Compare
|
| ) | ||
| val templateFormat = "ROC_1_23" | ||
| val query = SubjectQuery(faceSampleFormat = templateFormat) | ||
| val query = SubjectQuery( |
There was a problem hiding this comment.
Are the tests failing with the old implementation now?
There was a problem hiding this comment.
No Tests were OK.
I just added more parameters to one of the queries so that the tests covers all the flows in the filtering method
There was a problem hiding this comment.
My point is if they didn't catch the bug maybe they weren't :D



There was a bug in the identification callouts from CommCare due to incorrect filtering logic in CommCareIdentityDataSource. The filtering logic was unintentionally excluding all records, causing identification failures.
The issue arose when building the subjectQuery in BuildMatcherSubjectQueryUseCase, where the filtering logic failed under different partitionType conditions:
Due to this, the filtering logic always failed, as it did not account for null values correctly.
I updated the filtering logic to correctly handle null values to ensure that valid records are no longer filtered out incorrectly.