Missing config values 'error_message' and 'log_spam_attempts' in ai_webform_guard.settings

Created on 28 May 2025, about 2 months ago

Problem/Motivation

In the AI Webform Guard module, when someone submits a form, the module looks for two settings:

  • error_message – to show a custom message if the form is spam.
  • log_spam_attempts – to decide if it should log the spam attempt.

It looks for these in the configuration like this:

if ($classification === 'spam') {
        $message = $config->get('error_message') ?: $this->t('This submission has been identified as spam.');
        $form_state->setErrorByName('', $message);

        if ($config->get('log_spam_attempts')) {
          $this->loggerFactory->get('ai_webform_guard')->notice(
            'Spam attempt blocked on webform @id. Full AI response: @response',
            ['@id' => $webform_id, '@response' => $response_text]
          );
        }
      }

Steps to reproduce

  1. Install the AI Webform Guard module.
  2. Submit a Webform that is detected as spam.
  3. Check logs or try to set a custom error message — it won’t appear because the config keys don't exist.

Proposed resolution

Add the missing configuration values to:

  • config/install/ai_webform_guard.settings.yml
  • The settings form builder

Suggested default values:

error_message: ''
log_spam_attempts: true

Also update the settings form to allow the user to customise these.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇮🇳India prabha1997

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024