Discussed with @wim-leers and @pdureau at DrupalCon Vienna (Wim directed me to create an issue).

Overview

If the following conditions are true

  • I have a component with $ref: json-schema-definitions://canvas.module/image in the prop definition
  • The component is invoked
  • Canvas is not installed
  • justinrainbow/json-schema is installed

I get the following error. Note that if I pull down Canvas via composer and install it, the error disappears.

Very basic component attached.

The website encountered an unexpected error. Try again later.

JsonSchema\Exception\ResourceNotFoundException: file_get_contents(json-schema-definitions://canvas.module/image): Failed to open stream: No such file or directory in JsonSchema\Uri\Retrievers\FileGetContents->retrieve() (line 40 of /var/www/html/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php).
JsonSchema\Uri\UriRetriever->loadSchema() (Line: 183)
JsonSchema\Uri\UriRetriever->retrieve() (Line: 54)
JsonSchema\SchemaStorage->addSchema() (Line: 124)
JsonSchema\SchemaStorage->getSchema() (Line: 147)
JsonSchema\SchemaStorage->resolveRef() (Line: 179)
JsonSchema\SchemaStorage->resolveRefSchema() (Line: 115)
JsonSchema\Constraints\Constraint->checkUndefined() (Line: 139)
JsonSchema\Constraints\ObjectConstraint->validateProperties() (Line: 45)
JsonSchema\Constraints\ObjectConstraint->check() (Line: 83)
JsonSchema\Constraints\Constraint->checkObject() (Line: 66)
JsonSchema\Constraints\UndefinedConstraint->validateTypes() (Line: 43)
JsonSchema\Constraints\UndefinedConstraint->check() (Line: 115)
JsonSchema\Constraints\Constraint->checkUndefined() (Line: 95)
JsonSchema\Constraints\SchemaConstraint->check() (Line: 67)
JsonSchema\Validator->validate() (Line: 193)
Drupal\Core\Theme\Component\ComponentValidator->validateProps() (Line: 124)
Drupal\Core\Template\ComponentsTwigExtension->doValidateProps() (Line: 106)
Drupal\Core\Template\ComponentsTwigExtension->validateProps() (Line: 46)
__TwigTemplate_bf70da37f4cf060ab78449f54267b162->doDisplay() (Line: 402)
Twig\Template->yield() (Line: 358)
Twig\Template->display() (Line: 373)
Twig\Template->render() (Line: 51)
Twig\TemplateWrapper->render() (Line: 1520)
Twig\Extension\CoreExtension::include() (Line: 76)
__TwigTemplate_0fe34b0ef0d92db249abd2e0609952eb->doDisplay() (Line: 402)
Twig\Template->yield() (Line: 358)
Twig\Template->display() (Line: 373)
Twig\Template->render() (Line: 51)
Twig\TemplateWrapper->render() (Line: 34)
twig_render_template() (Line: 391)
Drupal\Core\Theme\ThemeManager->render() (Line: 492)
Drupal\Core\Render\Renderer->doRender() (Line: 222)
Drupal\Core\Render\Renderer->render() (Line: 491)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 93)
__TwigTemplate_b14229787cff2ba465c827ea7fe52251->doDisplay() (Line: 402)
Twig\Template->yield() (Line: 358)
Twig\Template->display() (Line: 373)
Twig\Template->render() (Line: 51)
Twig\TemplateWrapper->render() (Line: 34)
twig_render_template() (Line: 391)
Drupal\Core\Theme\ThemeManager->render() (Line: 492)
Drupal\Core\Render\Renderer->doRender() (Line: 222)
Drupal\Core\Render\Renderer->render() (Line: 162)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 622)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 157)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray() (Line: 246)
Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}() (Line: 206)
Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (Line: 56)
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (Line: 188)
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)

Proposed resolution

User interface changes

CommentFileSizeAuthor
test-ref.zip771 bytesmherchel

Issue fork canvas-3552121

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

mherchel created an issue. See original summary.

mherchel’s picture

Issue summary: View changes
mherchel’s picture

Issue summary: View changes
mherchel’s picture

mstrelan’s picture

This happens to me when I apply a recipe that applies two other recipes, one that includes navigation module and another that includes canvas module. If I remove navigation from the recipe then it installs fine. If I remove the components directory from navigation then it installs fine.

mstrelan’s picture

Version: 1.0.0-rc1 » 1.x-dev
Status: Active » Needs work

Added an MR with a failing test

effulgentsia’s picture

Status: Needs work » Closed (won't fix)

@mstrelan: thanks for reporting #5 and providing the failing test, but I think that's actually a separate issue (though the same error message so I can see why you flagged it here). I opened #3570043: Error installing a recipe that installs canvas and navigation simultaneously for it. Can you move your MR to there?

For the originally reported issue here (where Canvas is intentionally not installed), it was a bigger problem before #3515074: Shape matching MUST work with the resolved equivalents of $refs AND must be compatible with core's upcoming $ref resolving in SDCs, but now that that issue is in, the answer to wanting an SDC to work regardless of whether or not Canvas is installed is: don't depend on Canvas-provided schemas. With #3515074: Shape matching MUST work with the resolved equivalents of $refs AND must be compatible with core's upcoming $ref resolving in SDCs complete, you can instead duplicate that same schema elsewhere and still benefit from Canvas treating it the same way as when using the Canvas-provided one.

One could argue that Drupal core should have a more graceful failure mode than "the website encountered an unexpected error" when an SDC depends on JSON schema from a module that isn't installed, and if anyone wants to argue for that, please open a Drupal core issue for it if there isn't one already. There's nothing Canvas can do about it when Canvas isn't installed.

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.

mstrelan changed the visibility of the branch 3552121-test to hidden.