Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate extracted fhir resources while in debug #2874

Merged
merged 17 commits into from
Aug 7, 2024

Conversation

LZRS
Copy link
Contributor

@LZRS LZRS commented Nov 21, 2023

IMPORTANT: Where possible all PRs must be linked to a Github issue

Depends on #2825
Fixes #2853

Engineer Checklist

  • I have written Unit tests for any new feature(s) and edge cases for bug fixes
  • I have added any strings visible on UI components to the strings.xml file
  • I have updated the CHANGELOG.md file for any notable changes to the codebase
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the project's style guide
  • I have built and run the FHIRCore app to verify my change fixes the issue and/or does not break the app
  • I have checked that this PR does NOT introduce breaking changes that require an update to Content and/or Configs? If it does add a sample here or a link to exactly what changes need to be made to the content.

Code Reviewer Checklist

  • I have verified Unit tests have been written for any new feature(s) and edge cases
  • I have verified any strings visible on UI components are in the strings.xml file
  • I have verifed the CHANGELOG.md file has any notable changes to the codebase
  • I have verified the solution has been implemented in a configurable and generic way for reuseable components
  • I have built and run the FHIRCore app to verify the change fixes the issue and/or does not break the app

@LZRS LZRS self-assigned this Nov 21, 2023
Copy link

codecov bot commented Nov 21, 2023

Codecov Report

Attention: Patch coverage is 33.96226% with 35 lines in your changes missing coverage. Please review.

Project coverage is 27.1%. Comparing base (490c294) to head (045f2bc).
Report is 2 commits behind head on main.

Files Patch % Lines
...e/quest/ui/questionnaire/QuestionnaireViewModel.kt 0.0% 30 Missing ⚠️
...re/engine/util/extension/FhirValidatorExtension.kt 78.2% 3 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##              main   #2874    +/-   ##
========================================
  Coverage     27.0%   27.1%            
- Complexity     720     733    +13     
========================================
  Files          269     275     +6     
  Lines        13517   13756   +239     
  Branches      2433    2491    +58     
========================================
+ Hits          3662    3733    +71     
- Misses        9373    9528   +155     
- Partials       482     495    +13     
Flag Coverage Δ
engine 64.6% <78.2%> (+<0.1%) ⬆️
geowidget 11.4% <ø> (ø)
quest 5.2% <0.0%> (+0.4%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...re/engine/util/extension/FhirValidatorExtension.kt 78.2% <78.2%> (ø)
...e/quest/ui/questionnaire/QuestionnaireViewModel.kt 2.7% <0.0%> (-0.1%) ⬇️

@LZRS LZRS force-pushed the main-validate-extracted-resources branch from 3d36461 to f8b6965 Compare November 27, 2023 22:13
@LZRS LZRS force-pushed the main-validate-extracted-resources branch from f8b6965 to 33fd86e Compare December 1, 2023 03:18
@LZRS LZRS force-pushed the main-validate-extracted-resources branch 5 times, most recently from 8a36cfd to b74de76 Compare January 23, 2024 13:39
@LZRS LZRS marked this pull request as ready for review January 23, 2024 15:20
@LZRS LZRS enabled auto-merge (squash) January 23, 2024 15:41
@LZRS LZRS disabled auto-merge January 23, 2024 15:41
Copy link
Collaborator

@ellykits ellykits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor code change request. Otherwise looks good 👍

@LZRS LZRS force-pushed the main-validate-extracted-resources branch from b74de76 to 1cf49f6 Compare January 25, 2024 14:11
@LZRS LZRS marked this pull request as draft January 25, 2024 14:17
@LZRS LZRS added the DNM DO NOT MERGE label Jan 25, 2024
@LZRS
Copy link
Contributor Author

LZRS commented Jan 25, 2024

Getting this error

FATAL EXCEPTION: main
                                                                                                    Process: org.smartregister.opensrp.ecbis, PID: 6802
                                                                                                    java.lang.IllegalStateException: com.github.benmanes.caffeine.cache.SSMSW
                                                                                                    	at com.github.benmanes.caffeine.cache.LocalCacheFactory.newBoundedLocalCache(LocalCacheFactory.java:95)
                                                                                                    	at com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalManualCache.<init>(BoundedLocalCache.java:3417)
                                                                                                    	at com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache.<init>(BoundedLocalCache.java:3752)
                                                                                                    	at com.github.benmanes.caffeine.cache.Caffeine.build(Caffeine.java:1105)
                                                                                                    	at org.hl7.fhir.common.hapi.validation.validator.VersionSpecificWorkerContextWrapper.<init>(VersionSpecificWorkerContextWrapper.java:80)
                                                                                                    	at org.hl7.fhir.common.hapi.validation.validator.VersionSpecificWorkerContextWrapper.newVersionSpecificWorkerContextWrapper(VersionSpecificWorkerContextWrapper.java:770)
                                                                                                    	at org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator.provideWorkerContext(FhirInstanceValidator.java:246)
                                                                                                    	at org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator.validate(FhirInstanceValidator.java:225)
                                                                                                    	at org.hl7.fhir.common.hapi.validation.validator.BaseValidatorBridge.doValidate(BaseValidatorBridge.java:22)
                                                                                                    	at org.hl7.fhir.common.hapi.validation.validator.BaseValidatorBridge.validateResource(BaseValidatorBridge.java:45)
                                                                                                    	at org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator.validateResource(FhirInstanceValidator.java:26)
                                                                                                    	at ca.uhn.fhir.validation.FhirValidator.validateResource(FhirValidator.java:343)
                                                                                                    	at ca.uhn.fhir.validation.FhirValidator.doValidate(FhirValidator.java:264)
                                                                                                    	at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:252)
                                                                                                    	at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:211)
                                                                                                    	at org.smartregister.fhircore.engine.util.extension.FhirValidatorExtensionKt$checkResourceValid$2.invokeSuspend(FhirValidatorExtension.kt:34)
                                                                                                    	at org.smartregister.fhircore.engine.util.extension.FhirValidatorExtensionKt$checkResourceValid$2.invoke(Unknown Source:14)
                                                                                                    	at org.smartregister.fhircore.engine.util.extension.FhirValidatorExtensionKt$checkResourceValid$2.invoke(Unknown Source:12)
                                                                                                    	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78)
                                                                                                    	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:167)
                                                                                                    	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1)
                                                                                                    	at org.smartregister.fhircore.engine.util.extension.FhirValidatorExtensionKt.checkResourceValid(FhirValidatorExtension.kt:33)
                                                                                                    	at org.smartregister.fhircore.engine.util.extension.FhirValidatorExtensionKt.checkResourceValid$default(FhirValidatorExtension.kt:27)
                                                                                                    	at org.smartregister.fhircore.quest.ui.questionnaire.QuestionnaireViewModel$handleQuestionnaireSubmission$1.invokeSuspend(QuestionnaireViewModel.kt:219)
                                                                                                    	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                    	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:942)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:201)
                                                                                                    	at android.os.Looper.loop(Looper.java:288)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:7872)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
                                                                                                    	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@c8aef04, Dispatchers.Main.immediate]
                                                                                                    Caused by: java.lang.reflect.InvocationTargetException
                                                                                                    	at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                                                                    	at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
                                                                                                    	at com.github.benmanes.caffeine.cache.LocalCacheFactory.newBoundedLocalCache(LocalCacheFactory.java:92)
                                                                                                    	... 33 more
2024-01-25 17:16:51.374  6802-6802  AndroidRuntime          org.smartregister.opensrp.ecbis      E  Caused by: java.lang.Error: java.lang.NoSuchFieldException: No field threadLocalRandomProbe in class Ljava/lang/Thread; (declaration of 'java.lang.Thread' appears in /apex/com.android.art/javalib/core-oj.jar-transformed)
                                                                                                    	at com.github.benmanes.caffeine.cache.UnsafeAccess.objectFieldOffset(UnsafeAccess.java:57)
                                                                                                    	at com.github.benmanes.caffeine.cache.StripedBuffer.<clinit>(StripedBuffer.java:88)
                                                                                                    	at com.github.benmanes.caffeine.cache.BoundedLocalCache.<init>(BoundedLocalCache.java:243)
                                                                                                    	at com.github.benmanes.caffeine.cache.SS.<init>(SS.java:31)
                                                                                                    	at com.github.benmanes.caffeine.cache.SSMS.<init>(SSMS.java:64)
                                                                                                    	at com.github.benmanes.caffeine.cache.SSMSW.<init>(SSMSW.java:41)
                                                                                                    	... 36 more
                                                                                                    Caused by: java.lang.NoSuchFieldException: No field threadLocalRandomProbe in class Ljava/lang/Thread; (declaration of 'java.lang.Thread' appears in /apex/com.android.art/javalib/core-oj.jar-transformed)
                                                                                                    	at java.lang.Class.getDeclaredField(Native Method)
                                                                                                    	at com.github.benmanes.caffeine.cache.UnsafeAccess.objectFieldOffset(UnsafeAccess.java:55)
                                                                                                    	... 41 more

@LZRS LZRS changed the base branch from main to upgrade-sdk-libraries February 5, 2024 13:40
Base automatically changed from upgrade-sdk-libraries to main February 7, 2024 15:51
@LZRS LZRS force-pushed the main-validate-extracted-resources branch from fb327b9 to 27d7949 Compare March 11, 2024 00:24
@LZRS LZRS force-pushed the main-validate-extracted-resources branch 2 times, most recently from 882883f to f3fff5e Compare March 18, 2024 14:08
@LZRS
Copy link
Contributor Author

LZRS commented Mar 19, 2024

  • Allow normal questionnaire submission

  • Collect validation errors on CQL evaluations

  • Collect validation errors on StructureMap extractions

  • Collect validation errors on PlanDef extractions

  • Refine validation error dialog with clear details

Submission seems somewhat slowed down because of validation

@pld
Copy link
Member

pld commented Apr 18, 2024

hi @LZRS is the only remaining issue that the error dialogs are not great? I think we should get this merged and have that be in a cleanup issue cc @ellykits @ndegwamartin

@LZRS
Copy link
Contributor Author

LZRS commented Apr 18, 2024

hi @LZRS is the only remaining issue that the error dialogs are not great? I think we should get this merged and have that be in a cleanup issue cc @ellykits @ndegwamartin

Yeah it is the only remaining issue. I can finish up on the tests and have it as ready for review

@LZRS LZRS force-pushed the main-validate-extracted-resources branch from f315d06 to 3ca54c0 Compare April 29, 2024 23:36
@LZRS LZRS force-pushed the main-validate-extracted-resources branch from 3ca54c0 to e093834 Compare April 30, 2024 08:05
@pld
Copy link
Member

pld commented Jun 17, 2024

@LZRS I think this'll be good to go with a bit more coverage!

@ellykits you have a requested changes open, can you please take another look?

Thank you!

@pld pld force-pushed the main-validate-extracted-resources branch from 69aeb05 to 452efa7 Compare June 17, 2024 20:32
vararg resource: Resource,
isDebug: Boolean = BuildConfig.BUILD_TYPE.contains("debug", ignoreCase = true),
): List<ValidationResult> {
if (!isDebug) return emptyList()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean validation will only be triggered for debug apks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it would only be triggered for debug because the performance implications it might have for non-debug apps

@ndegwamartin
Copy link
Contributor

Recommending we strip out the UI stuff in this version, see my comment here.

@LZRS LZRS force-pushed the main-validate-extracted-resources branch from dc4c215 to 5e59ef5 Compare July 27, 2024 02:06
@LZRS LZRS marked this pull request as ready for review August 7, 2024 09:52
@ellykits
Copy link
Collaborator

ellykits commented Aug 7, 2024

@LZRS Create a follow-up GitHub issue based on @ndegwamartin's comment below.

Recommending we strip out the UI stuff in this version, see #2853 (comment).

@ellykits ellykits merged commit 8b5d9f6 into main Aug 7, 2024
4 of 5 checks passed
@ellykits ellykits deleted the main-validate-extracted-resources branch August 7, 2024 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DNM DO NOT MERGE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for validating resources before saving to local db
6 participants