GoogleCloudPlatform / recaptcha-enterprise-mobile-sdk

Apache License 2.0
31 stars 6 forks source link

Error getting client, Couldn't find 3-letter Country code for EN_US #61

Closed carlosjuarezflash closed 1 year ago

carlosjuarezflash commented 1 year ago

Describe the bug

A clear and concise description of what the bug is.

I'm recently updated to version 18.2.1 while trying to get a captcha client it is failing

the log says the following:

java.util.MissingResourceException: Couldn't find 3-letter country code for EN_US at java.util.Locale.getISO3Country(Locale.java:1790) at com.google.android.recaptcha.internal.zzah.zzc(com.google.android.recaptcha:recaptcha@@18.2.1:10) at com.google.android.recaptcha.internal.zzai.zze(com.google.android.recaptcha:recaptcha@@18.2.1:2) at com.google.android.recaptcha.internal.zzai.zzd(com.google.android.recaptcha:recaptcha@@18.2.1:4) at com.google.android.recaptcha.internal.zzdi.zzq(com.google.android.recaptcha:recaptcha@@18.2.1:5) at com.google.android.recaptcha.internal.zzdi.zzg(com.google.android.recaptcha:recaptcha@@18.2.1:15) at com.google.android.recaptcha.internal.zzv.zza(com.google.android.recaptcha:recaptcha@@18.2.1:17) at com.google.android.recaptcha.internal.zzv.zzb(com.google.android.recaptcha:recaptcha@@18.2.1:2) at com.google.android.recaptcha.Recaptcha$getClient$2$1.invokeSuspend(com.google.android.recaptcha:recaptcha@@18.2.1:3) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) 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:7918) 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)

reCAPTCHA Site Key

Please include your site key so we can examine backend metrics for your integration.

6Lcu1xwlAAAAAEXCqGXp0ZtYgpgHHABm_CVe1qnl

Integration Method

Select the method used to integrate with reCAPTCHA Mobile.

SDK Version (e.g. 18.0.1): 18.2.1

To Reproduce

Steps to reproduce the behavior:

Retrieve a captcha client using the following:

Recaptcha.getClient(application, authKey) .onSuccess { client -> instance = client } .onFailure { exception -> exception.printStackTrace() instance = null }

It will return .onFailure with the stackTrace printed above

Expected behavior

A clear and concise description of what you expected to happen.

i expect to receive a captcha client so that i can process sign up and payments

Screenshots

If applicable, add screenshots to help explain your problem.

Xcode version for iOS (please complete the following information):

Device (please complete the following information):

Additional context

Add any other context about the problem here.

carlosjuarezflash commented 1 year ago

Found out that our application was setting a wrong Locale like this:

  val lang = sharedPref?.getString("language", Locale.getDefault().toString())
  val locale = Locale(lang!!.substringBefore("-"), lang.substringAfter("-"))
  Locale.setDefault(locale)

so, locale contained a wrong locale with a null getISO3Country

fixed the problem by not setting the correct Locale as "en-Us"

mcorner commented 1 year ago

Thanks, we had found the same thing. Glad you have a fix, but we will make the sdk robust against this as well. Thanks for the bug report!

heetchKarakasli commented 1 year ago

Hi @mcorner ,

A pretty similar issues from our side.

Integration Method: GMaven (Android)

SDK Version: 18.2.1

We have recognized on firebase crashlytics;

Fatal Exception: java.util.MissingResourceException: Couldn't find 3-letter country code for IC
       at java.util.Locale.getISO3Country(Locale.java:1725)
       at com.google.android.recaptcha.internal.zzah.zzc(com.google.android.recaptcha:recaptcha@@18.2.1:10)
       at com.google.android.recaptcha.internal.zzai.zze(com.google.android.recaptcha:recaptcha@@18.2.1:2)
       at com.google.android.recaptcha.internal.zzai.zzd(com.google.android.recaptcha:recaptcha@@18.2.1:4)
       at com.google.android.recaptcha.internal.zzaz.zzb(com.google.android.recaptcha:recaptcha@@18.2.1:33)
       at com.google.android.recaptcha.internal.zzdg.invokeSuspend(com.google.android.recaptcha:recaptcha@@18.2.1:8)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
       at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
       at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
       at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:570)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

There are cases for countries from now on; IC: Canary Island, XK: Kosovo,

causes to crashes on client side because of error which I shared above.

mcorner commented 1 year ago

We will have a more permanent fix for this in the next SDK release (RSN).