Unable to complete initial configuration due to form error.

Created on 23 August 2023, 10 months ago
Updated 19 April 2024, 2 months ago

Problem/Motivation

I am unable to submit the Fastly General configuration form. When I do so, I receive the following error:
TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, no array or string given in call_user_func() (line 275 of /app/web/core/lib/Drupal/Core/Render/Element/MachineName.php)

Steps to reproduce

1. Install and enable the Fastly module.
2. Enter the site id, API key and select a service.
3. Save configuration.
4. Error. Logs show:
TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, no array or string given in call_user_func() (line 275 of /app/web/core/lib/Drupal/Core/Render/Element/MachineName.php)

Proposed resolution

I've seen this issue crop up in a number of modules. Generally, the issue is that there is a missing 'exists' handler for a form field of type machine_name. In this case, it looks like it's the site id field.

This is my first exposure to this module, so I'm not sure if I'm the one to create this fix.

Thank you!

πŸ› Bug report
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bgronek

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

Comments & Activities

  • Issue created by @bgronek
  • πŸ‡¨πŸ‡¦Canada sleepingmonk Vancouver Island πŸ‡¨πŸ‡¦

    The site_id field uses the "machine_name" form element. I presume to ensure proper characters are used.

    The "machine_name" element also requires a check for duplicate machine names and this form does not provide a callback for this. What would it check for duplicates?

    I think this may be the wrong field type to use for this. If we are only concerned with ensuring proper name format, it's better to check with field validation and provide a helpful error message.

    I've attached a patch that changes the field type to "textfield", adds helpful instruction in the field description, and validates to ensure only letters, numbers, hyphens and underscores are used.

    If I'm misunderstanding the purpose of using the machine name element here, please let me know.

  • πŸ‡¨πŸ‡¦Canada sleepingmonk Vancouver Island πŸ‡¨πŸ‡¦
Production build 0.69.0 2024