Overview
Testing out XB for the first time in a while (so exciting!), I ran into several 500 errors caused by invalid component definitions.
While this was invalid JSON Schema, this page should never fail. It should highlight the errors of my ways.
Fortunately @penyaskito helped me out in Slack!
First error
The first error was caused by me setting the format
key as an array in a prop
Example:
href:
title: Link
type: string
format:
- url:
examples: [ 'http://www.drupal.org' ]
Error
The website encountered an unexpected error. Try again later.
TypeError: Drupal\experience_builder\JsonSchemaInterpreter\JsonSchemaStringFormat::from(): Argument #1 ($value) must be of type string, array given in Drupal\experience_builder\JsonSchemaInterpreter\JsonSchemaStringFormat::from() (line 210 of modules/contrib/experience_builder/src/JsonSchemaInterpreter/SdcPropJsonSchemaType.php).
Drupal\experience_builder\JsonSchemaInterpreter\SdcPropJsonSchemaType->computeStorablePropShape() (Line: 149)
Drupal\experience_builder\PropShape\PropShape->getStorage() (Line: 63)
Drupal\experience_builder\ComponentMetadataRequirementsChecker::check() (Line: 292)
Drupal\experience_builder\Plugin\ExperienceBuilder\ComponentSource\SingleDirectoryComponent::componentMeetsRequirements() (Line: 94)
Drupal\experience_builder\Plugin\ComponentPluginManager->setCachedDefinitions() (Line: 214)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 39)
Drupal\experience_builder\Controller\ComponentStatusController->__invoke()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 53)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 715)
Drupal\Core\DrupalKernel->handle() (Line: 19)
Second error: invalid Attributes
The second error was caused by me passing attributes as a string
props:
type: object
properties:
summary_attributes:
type: string
title:
type: string
Error
The website encountered an unexpected error. Try again later.
AssertionError: assert($prop_schema['type'][0] === Attribute::class) in assert() (line 96 of modules/contrib/experience_builder/src/PropShape/PropShape.php).
Drupal\experience_builder\PropShape\PropShape::getComponentPropsForMetadata() (Line: 51)
Drupal\experience_builder\ComponentMetadataRequirementsChecker::check() (Line: 292)
Drupal\experience_builder\Plugin\ExperienceBuilder\ComponentSource\SingleDirectoryComponent::componentMeetsRequirements() (Line: 94)
Drupal\experience_builder\Plugin\ComponentPluginManager->setCachedDefinitions() (Line: 214)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 39)
Drupal\experience_builder\Controller\ComponentStatusController->__invoke()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 53)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 715)
Drupal\Core\DrupalKernel->handle() (Line: 19)