ambethia / recaptcha

ReCaptcha helpers for ruby apps
http://github.com/ambethia/recaptcha
MIT License
1.96k stars 439 forks source link

Timeout related error message is unclear #436

Open Jhunter1 opened 6 months ago

Jhunter1 commented 6 months ago

We recently had an issue with a slow DNS lookup (10 seconds) on our Ruby on Rails web server which caused the code to timeout and fail after about 10 seconds. This error message could be made clearer I think for future users facing similar issues?

"Oops, we failed to validate your reCAPTCHA response. Please try again."

https://github.com/ambethia/recaptcha/blob/master/test/verify_test.rb

grosser commented 6 months ago

Are you suggesting it raises and the user sees a 500 ? Ideally the user would get a nice "Captcha failed because of an internal error" message (new translation). ... but just raising could be fine too since then the caller can chose to retry.

On Wed, Jan 3, 2024 at 7:07 AM Jhunter1 @.***> wrote:

We recently had an issue with a slow DNS lookup issue (10 seconds) on our Ruby on Rails web app which caused the code to timeout and fail after about 10 seconds. This error message could be made clearer I think for future users facing similar issues?

"Oops, we failed to validate your reCAPTCHA response. Please try again."

https://github.com/ambethia/recaptcha/blob/master/test/verify_test.rb

— Reply to this email directly, view it on GitHub https://github.com/ambethia/recaptcha/issues/436, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACYZ37WENGSWUAXSHCNMLYMVX4BAVCNFSM6AAAAABBLSCMZSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA3DIMJZGI2TINA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Jhunter1 commented 6 months ago

In our case the client doesn't get a 500 error - they only get the custom error message that has been added to our website's code. The error from the recaptcha Gem is "Oops, we failed to validate your reCAPTCHA response. Please try again." and we send that to a log file/Rails.logger.warn as shown below:

if verify_recaptcha(model: @user)
      @user.deliver_reset_password_instructions! if @user
      redirect_to(root_path, :notice => 'Instructions have been sent to your email.')
    else
        Rails.logger.warn("recapthca error #{@user.errors.full_messages}")
        flash[:alert] = "recaptcha not verified!"
        render :action => :new
    end

I am not a full time dev so I will leave it up to you to decide if it is worth changing the error message and if it can be helpful for others