Problem/Motivation

When installing the canvas module using drush (or likely through the UI), a ValueError is thrown because the JsonSchemaInterpreter\JsonSchemaType enum attempts to process a "null" value from a component's JSON schema definition, which it doesn't currently support.
The error prevents the successful installation and full functionality of the canvas module and any themes or modules that depend on it (such as the Radix theme).

[error] ValueError: "null" is not a valid backing value for enum Drupal\canvas\JsonSchemaInterpreter\JsonSchemaType in Drupal\canvas\JsonSchemaInterpreter\JsonSchemaType::from() (line 100 of /var/www/html/local1.osc.ny.gov/docroot/modules/contrib/canvas/src/PropShape/PropShape.php) #0 /var/www/html/local1.osc.ny.gov/docroot/modules/contrib/canvas/src/PropShape/PropShape.php(100): Drupal\canvas\JsonSchemaInterpreter\JsonSchemaType::from('null')

Steps to reproduce

  1. Set up a standard Drupal 9/10 environment.
  2. Ensure both the radix theme and the canvas module are available in the codebase (e.g., via Composer).
  3. Attempt to install the module via Drush:
  4. bash
  5. drush pm:install canvas
    # or install the radix theme, which depends on canvas
    drush theme:enable radix
  6. The installation fails with the ValueError during the cache rebuild phase (hook_rebuild within the canvas.install file).
  7. The stack trace indicates the issue is specifically triggered when processing the metadata for the radix:fieldset component, which likely has a property defined in its schema that includes a null type option.
  8. Specific files involved: The issue is present in the component definition files for radix:fieldset, radix:form-element, and radix:form-element--label. These files contain a type array in their props definitions where 'null' appears before another valid type (e.g., type: ['null', 'boolean']).

Proposed resolution

  1. The immediate workaround is to manually reorder the type array in the component YAML files so that a valid, supported type (like 'boolean', 'string', etc.) appears before 'null'.
  2. Uninstall conflicting modules: In at least one environment, uninstalling the "Restrict IP" module allowed the installation to complete successfully, suggesting an environmental conflict may be a contributing factor.

The canvas module needs a robust fix in its schema interpretation logic (Drupal\canvas\PropShape\PropShape::normalizePropSchema or related methods) to handle the null type correctly within a multi-type array, regardless of its position.

This issue might be related to how Drupal Core handles enums and patches in certain versions, as discussed in Drupal Core Issue #3531905. Applying the relevant core patch might also be necessary in some environments.

Issue fork radix-3557451

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

joarferme created an issue. See original summary.

kurttrowbridge’s picture

I just ran into this on a brand new Drupal 11 install (with no non-standard modules enabled yet aside from Canvas), and the patch fixed it. Thanks! I'll let someone else mark RTBC since this is my first time testing both Canvas and Radix.

doxigo’s picture

smart workaround for now until this is fixed in core, thanks and merged.

doxigo’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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