Problem/Motivation
I'm using Drupal 11 and a Drupal CMS project. The Civic Theme is installed with a subtheme. The subtheme is currently enabled. Regardless of which is the default theme, I'm getting a page error when I open the site.
The website encountered an unexpected error. Try again later.
Drupal\Core\Render\Component\Exception\InvalidComponentException: [civictheme:text-icon/is_new_window] NULL value found, but a boolean or an object is required. This may be because the property is empty instead of having data present. If possible fix the source data, use the |default() twig filter, or update the schema to allow multiple types.. [civictheme:text-icon/is_external] NULL value found, but a boolean or an object is required. This may be because the property is empty instead of having data present. If possible fix the source data, use the |default() twig filter, or update the schema to allow multiple types.. [civictheme:text-icon/icon] NULL value found, but a string or an object is required. This may be because the property is empty instead of having data present. If possible fix the source data, use the |default() twig filter, or update the schema to allow multiple types.. in Drupal\Core\Theme\Component\ComponentValidator->validateProps() (line 242 of core/lib/Drupal/Core/Theme/Component/ComponentValidator.php).These are common with many lower-level components including heading, field, and link.
For example:
Drupal\Core\Render\Component\Exception\InvalidComponentException: [civictheme:skip-link/theme] NULL value found, but a string or an object is required.
Drupal\Core\Render\Component\Exception\InvalidComponentException: [civictheme:heading/level] Integer value found, but a string is required.
Steps to reproduce
- Install CivicTheme.
- Set up component validation as described here * Make sure that the
justinrainbow/json-schemalibrary is in your vendor/ directory - Install devel module
- [optional] Set up your local environment to use a settings.local file, based on Drupal's default example.settings.local.php file
(* Note that other modules or composer configuration could also include the justinrainbow/json-schema library. For example, it is a dependency of acquia-cms-starterkit)
Installing devel module seems to be the key to triggering these errors. Setting up your settings.local will just make this error appear directly on the screen rather than the standard WSOD message.
Proposed resolution
Fix component validation issues.
Note that setting enforce_prop_schemas: false in the subtheme's info file does not prevent these errors from occurring. See: Documentation on component data validation
Issue fork civictheme-3546743
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
Comment #2
james.leach09@gmail.com commentedI am also getting this issue as well, is there a recommended resolution? I have reverted to a standard theme and it seems to work fine.
Comment #3
ronraney commentedIt has been mentioned that if using the recipe, there are no issues. Might be worth investigating. I don't know how to go from Github code to using a recipe.
https://www.drupal.org/project/civictheme/issues/3517643
Comment #4
richardgaunt commentedComment #5
megan_m commentedI think I tracked down the source of this.
I was able to set up CivicTheme with no problems on a clean vanilla Drupal profile, but when I tried to set it up on a site hosted on Acquia's cloud platform I got similar errors to the above. Example:
Drupal\Core\Render\Component\Exception\InvalidComponentException: [civictheme:heading/level] Integer value found, but a string, an object or a null is required. The provided value is: "1". in Drupal\Core\Theme\Component\ComponentValidator->validateProps() (line 255 of core/lib/Drupal/Core/Theme/Component/ComponentValidator.php).So why was it happening on the Acquia site but not my vanilla Drupal site? Composer. Some of the dependencies in the Acquia standard profile were requiring the justinrainbow/json-schema library. If I delete that from my vendor directory, the theme starts working again (with errors about that library being missing).
Quick fix: remove the justinrainbow/json-schema library from your vendor directory.
I'm not sure exactly which acquia/ dependencies are requiring that library. Definitely
acquia/coding-standardsbut I think there are others.Comment #6
ronraney commentedMy site doesn't have a justinrainbow/json-schema library in the vendors directory.
I must have eventually worked through it. I haven't seen this error for a while. I'm sorry I don't know what I did for it to go away.
Comment #7
fionamorrison23 commentedComment #8
fionamorrison23 commentedComment #9
megan_m commentedThis is relevant:
https://www.drupal.org/docs/develop/theming-drupal/using-single-director...
I'm going to change the title here to something like "Fix component validation".
I have done some work in my subtheme to try to get some of these issues fixed. There are a lot of issues with atom level components like heading or label. Problems with components not getting the right theme value are common but there are others. It's hard to find out where those are coming from so they could be fixed further up.
Comment #10
megan_m commentedComment #11
megan_m commentedAlso relevant: justinrainbow/json-schema moved to a production dependency of Drupal core
More common problems: the link component and boolean prop types (often getting 1/0 not true/false).
Comment #12
megan_m commentedComment #13
richardgaunt commentedWe are not enforcing prop schemas in CivicTheme for now - partially due to legacy slots that we are not exposing in the component schema.
I am closing this issue for now as I belive this relates to the starter kit theme accidentally having enforce_schema set.
Comment #14
richardgaunt commentedComment #16
fionamorrison23 commentedComment #17
richardgaunt commentedWe will take a look at the validation issues and fix
Comment #18
fionamorrison23 commentedComment #19
fionamorrison23 commentedComment #21
richardgaunt commentedThis has been merged into the dev version of CivicTheme
https://github.com/civictheme/monorepo-drupal/pull/1483
https://github.com/civictheme/uikit/pull/892
So feel free to install and see how it works for you with using ddev with zend.assertions=1
@danielgry this will need a thorough QA test, you are looking for any white screen errors from validation. This can be covered in release smoke test as it affects the entire site.
Comment #24
cbHi @Richard another small MR after we chatted.
https://git.drupalcode.org/project/civictheme/-/merge_requests/24
Comment #25
richardgaunt commentedComment #26
richardgaunt commentedThanks this was a big effort appreciate everyone's work in resolving.
Comment #27
richardgaunt commented