NOTE: This is for a form that is embedded in a node as a paragraph. In the Form Settings page the form ID of the Captcha Point is webform_submission_contact_node_10_add_form.

Recaptcha V3 not working on a contact form.

Submitting a form with Captcha V3 always fails and falls back to the secondary validation method. The error message in Recent Log Messages is:

Google reCAPTCHA v3 validation failed: The response parameter is missing.

Interestingly enough the secondary method also tries to submit during the initial posting of the form and if logging is enabled it will indicate that the secondary method was entered without a value. For instance, if the secondary method is Math, it will report:

webform_submission_contact_node_10_add_form post blocked by CAPTCHA module: challenge Math (by module captcha), user answered "", but the solution was "6".

Steps to reproduce

  1. Add a contact webform to a node as a paragraph.
  2. Within the Captcha/ReCaptcha configuration pages add a reCaptcha V3 Action.
  3. In Captcha Form Settings add a Captcha Point for your Webform (form_id).
  4. Submit the form.
  • Captcha Caching is not enabled.
  • Turning off Caching for the site in Performance -> Caching makes no difference but this is a Pantheon hosted site and there may be other caching going on that is beyond our control.
CommentFileSizeAuthor
#20 fix-missing-user-response.patch943 bytesmandras87
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

awasson created an issue. See original summary.

dench0’s picture

@awasson
I can't reproduce, but I suppose that my config is diff from your because in my case webform id is webform_submission_contact_paragraph_1_add_form
Can you export paragraph and node configurations with related fields, or at least provide screenshots of the fields configuration?

avpaderno’s picture

Title: Google reCAPTCHA v3 validation failed: The response parameter is missing. » Google reCAPTCHA v3 validation failed: The response parameter is missing
Version: 8.x-1.5 » 8.x-1.x-dev
paulmckibben’s picture

I am having a similar problem with 8.x-1.5, but with a slightly different log message. Downgrading to 8.x-1.4 resolves the problem for me. The recaptcha is on a webform placed on a page as a layout builder block.

What I saw in the logs:
Google reCAPTCHA v3 validation failed: The response parameter is invalid or malformed. Expected hostname did not match. Expected action did not match.

I also set a breakpoint in recaptcha_v3.module, line 208. What I saw there was $user_input['captcha_response'] was an empty string.

avpaderno’s picture

@paulmckibben May you post the error message you see?

paulmckibben’s picture

Hi @apaderno, the error message in the Drupal log was:

Google reCAPTCHA v3 validation failed: The response parameter is invalid or malformed. Expected hostname did not match. Expected action did not match.

Also, when I tried to diagnose the problem using xdebug, I set a breakpoint in recaptcha_v3.module, line 208. What I saw there was $user_input['captcha_response'] was an empty string.

mnico made their first commit to this issue’s fork.

mnico’s picture

Hello, I also had the problem and reviewing I could see that when migrating from core/jquery.once to core/once it was still considered to use var element = this, when the element variable must come as an argument in forEach(). Check the patch: https://git.drupalcode.org/project/recaptcha_v3/-/merge_requests/2.diff

With this I was able to solve it

Regards

anup.singh’s picture

+1 , the suggestion from #9 worked for me too.

this was always "undefined"

mnico’s picture

Status: Active » Needs review
awasson’s picture

@dench0,
I can take any screenshots to help. Let me know what you'd like. The Paragraph Config for my Webform bundle or the Display Settings? I've got a field on Basic Page called Paragraphs where I place them. I can also export the configs. Let me know which ones you'd like as in Basic Page + Paragraph bundle + fields.

Interestingly enough on a local clone of the site, I get a similar error to #6 @paulmckibben where it says The response parameter is invalid or malformed. Expected hostname did not match.

In the meantime, I'll try the patch on #9 and see if that allows the Recapcha to complete.

Cheers,
Andrew

awasson’s picture

Just following up.

The patch at #9 appears to be working. I don't have any way to test to make sure that it will block spam but it isn't blocking legitimate submissions and no errors are reported. This could be the fix.

@dench0,
Just to follow up on the difference of the Captcha Point in the Form Settings. I have my Paragraph Field Display settings to Set submission source entity: No whereas I am certain you have yours set to Yes. I have tried it both ways prior to patching the module and neither way worked for me.

When I had mine set to Yes, my Captcha Point in the Form Settings was set to: webform_submission_contact_paragraph_232_add_form

Cheers,
Andrew

kurttrowbridge’s picture

Status: Needs review » Reviewed & tested by the community

The supplied patch is working here as well—we had a site with the same error described in the original issue, and the patch has restored the ability to submit forms that weren't working without it. Based on that and #13 above, marking as RTBC. Thanks for the quick turnaround on this!

  • dench0 committed ee6316c on 8.x-1.x authored by mnico
    Issue #3274900 by mnico, awasson, anup.singh, KurtTrowbridge: Google...
dench0’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, guys, I merged it and going to create a new release.

awasson’s picture

Thanks @dench0,

Nice turnaround on the fix and excellent work on that patch @mnico.

Cheers,
Andrew

jimconte’s picture

FYI this also impacts ReCaptcha V3 when implemented as a component of Webform "captcha"

Thanks for the fix!

-Jim

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mandras87’s picture

StatusFileSize
new943 bytes

If anybody still got this error, this patch may help you
It's fix a JS issue that cause the error "The response parameter is missing" (with no errors in console logs)
If needed, here the documentation for the jQuery each method: https://api.jquery.com/each/

dench0’s picture

Hi @Mandras87,

You definitely using the old code. The new one uses javascript forEach instead of jQuery each.

https://git.drupalcode.org/project/recaptcha_v3/-/blob/8.x-1.x/js/recapt...

dench0’s picture

seanr’s picture

This is still extant in 2.0.2

poker10’s picture

@seanr Can you open a new issue for this? We are also getting similar errors from bots even on 2.0.2.

Google reCAPTCHA v3 validation failed: The response parameter is invalid or malformed. Expected action did not match.
Google reCAPTCHA v3 validation failed: The response parameter is invalid or malformed. Expected hostname did not match. Expected action did not match.
karing’s picture

Is there a new issue for this? I just noticed this exact error on a /form - Drupal 10.3

Google reCAPTCHA v3 validation failed: The response parameter is invalid or malformed. Expected hostname did not match. Expected action did not match.

Even after updating to latest versions:

root@1e5e6035d98e:/var/www/drupal# sudo -u drupal composer require 'drupal/captcha:^2.0'
root@1e5e6035d98e:/var/www/drupal# sudo -u drupal composer require 'drupal/recaptcha_v3:^2.0'
orkutmuratyilmaz’s picture

@dench0 can you reactivate this issue?

sébastien-fr’s picture

I just configured recaptcha v3 with v2 in fall back. I also have this error in the logs.

Google reCAPTCHA v3 validation failed: The response parameter is missing.

The form is /user/register

Module :
CAPTCHA 2.0.7
reCAPTCHA 8.x-3.4
reCAPTCHA v3 2.0.3

dench0’s picture

@sébastien-fr

1. Are there any errors in the browser console?
2. Check this commentary . Do you see the element and does it have a value?
3. Check if the captcha value is sent with form data on form submission.

There are some similar issues, you can review them as well.

Someone helped just create a new site in the google console.

sébastien-fr’s picture

Hello @dench0

The markup seems ok :

<input id="recaptcha-v3-token" class="recaptcha-v3-token form-control" data-recaptcha-v3-action="recaptcha_v3" data-recaptcha-v3-site-key="...

How can I check if the captcha value is sent with form data on form submission on a registration form ?

dench0’s picture

The markup seems ok

Is there a token value?

How can I check if the captcha value is sent with form data on form submission on a registration form ?

In the browser developer tools - on the network tab.

Again this was already discussed in some of the previous issues: e.g. here.

I don't mean to be rude, but I highly recommend that you check issues before creating a new question: there are only 15 issues with the "Google reCAPTCHA v3 validation failed" and it should not take a lot of time to check them.

subir_ghosh’s picture

I am getting this in 2.0.4.

The response seems to be related only to bots.