Problem/Motivation
Successful reCaptcha challenges (with green tick) prevents forms from being submitted and shows an error saying the Captcha entered is incorrect (despite google ticking it green and passing it).
The error in the logs shows the following:
Not a success, but no error codes received!
Which corresponds to 'unknown-error' in the module meaning it's not one of the official recognised error codes.
The problem is if the $code is not one of the recognised ones then this check if (!isset($error_codes[$code])) {
simply defaults to 'unknown-error', thus 'hiding' the actual message returned from Google.
In our case the 'code' returned was:
"Over Enterprise free quota. Please ensure your project has an active billing account: https://cloud.google.com/recaptcha-enterprise/billing-information"
We had a sudden influx or traffic over 2 days which meant it very quickly went over the 10,000 free quota, but there was no way of knowing this was the issue until we printed out the actual response from them.
I can see that a similar error code array exists in recaptcha_v3 (which is what failed for us first which then failed back to v2) so a similar issue would exist there too. I will raise an issue on that queue as well.
The same issue applies to D7 version of the module.
Proposed resolution
At first I thought of adding a new code to handle 'billing' errors and then check for a string match (the 'code' returned is not a code but simply a free text message as above).
But then I thought if there are any other unknown errors that Google might return at some point in the future (or even now that we don't know of), then it's probably best to let it default to the 'unknown error', but log the original message from Google as well to let people know what the underlying issue actually is.
Remaining tasks
User interface changes
API changes
Data model changes