fix(recaptcha, integrity): Implement robust error handling and explicit status propagation#3622
Open
camaleon03 wants to merge 1 commit into
Open
fix(recaptcha, integrity): Implement robust error handling and explicit status propagation#3622camaleon03 wants to merge 1 commit into
camaleon03 wants to merge 1 commit into
Conversation
…it status propagation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR addresses edge-case failures within both the
play-services-recaptchaandplay-services-integrity(vending-app) modules where system exceptions or communication timeouts were flattened into generic internal errors or left unresolved. By capturing these exceptions dynamically and converting them into explicit GMS status codes, client SDKs (such as Firebase App Check) can execute their native fallback pathways rather than hanging or resorting to unauthenticated placeholder tokens.Detailed Changes
1. reCAPTCHA Enterprise Module Enhancement
RecaptchaWebImpl.kt: Enclosed the javascript execution coroutine and its 10-second delay within a structuredtry-catchblock. On execution failure or a timeout state:webViewinstance loading.about:blankand nullifying the instance reference to eliminate stale contexts.ApiExceptionembeddingRecaptchaStatusCodes.RECAPTCHA_FEATURE_OFF.RecaptchaService.kt: Updated the invocation catch blocks inRecaptchaServiceImpl. Instead of blindly invoking callbacks with a staticStatus.INTERNAL_ERROR, it attempts to safely resolve the exact status from theApiException. It passes the true status context directly down toonHandle,onData, andonResults.2. Play Integrity API Module Enhancement
IntegrityService.kt: EnhancedrequestIntegrityTokenagainst silent failures across the DroidGuard and token retrieval pipeline:try-catch. Failures or internal error prefixes (INTEGRITY_PREFIX_ERROR) now explicitly trigger aStandardIntegrityExceptionbound toIntegrityErrorCode.CANNOT_BIND_TO_SERVICE.IntegrityErrorCode.API_NOT_AVAILABLEinstead of masking it as a generic internal issue..onFailureresolution. It dynamically resolves the exception code via(it as? StandardIntegrityException)?.codeand incorporates a fallback to the bound requestpackageNameifintegrityDataremains uninitialized, guaranteeing reliable IPC/Binder execution under heavy failure states.Types of changes
Closes #2851