I've come across the Exception below. It seems this happens when Views is trying to figure out %1 !1, %2, or !2. This this case... I have 2 contextual filters. This only happens if I set the "More Link" to the following settings:
More Link: Yes
[X] Create More Link
[X] Always display more link
Link Display: Custom
[ ] None
[X] Custom URL
Custom URL: "/somepage"
All the tokens sent to view in this case are the following:
'{{ arguments.null }}' => string(2) "63"
'{{ raw_arguments.null }}' => string(2) "63"
'{{ arguments.field_degree_program_target_id }}' => string(4) "6605"
'{{ raw_arguments.field_degree_program_target_id }}' => string(4) "6605"
'%1' => ''
'!1' => string(2) "63"
'%2' => ''
'!2' => string(4) "6605"
The expected results would be to have the correct variable name for the replacement so that this validation will work.... or to change the validation where it's not a "hard Exception", but something that will fail softly.
AssertionError: Tokens need to be valid Twig variables. in Drupal\Component\Assertion\Handle::Drupal\Component\Assertion\{closure}() (line 367 of core/modules/views/src/Plugin/views/PluginBase.php).
assert('preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $token) === 1', 'Tokens need to be valid Twig variables.') (Line: 367)
Drupal\views\Plugin\views\PluginBase->viewsTokenReplace('/faculty', Array) (Line: 2080)
Drupal\views\Plugin\views\display\DisplayPluginBase->renderMoreLink() (Line: 2164)
Drupal\views\Plugin\views\display\DisplayPluginBase->elementPreRender(Array)
call_user_func(Array, Array) (Line: 381)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 448)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 468)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 84)
__TwigTemplate_b30d5878476cc595a2585c141ab5c83b010a9e8831025f3b5bfa0e1e9e2289df->block_content(Array, Array) (Line: 167)
Twig_Template->displayBlock('content', Array, Array) (Line: 73)
__TwigTemplate_b30d5878476cc595a2585c141ab5c83b010a9e8831025f3b5bfa0e1e9e2289df->doDisplay(Array, Array) (Line: 387)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 355)
Twig_Template->display(Array) (Line: 366)
Twig_Template->render(Array) (Line: 64)
twig_render_template('themes/custom/customtheme/templates/blocks/block.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('block', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 448)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 468)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 107)
__TwigTemplate_740a486138a3a9fc024c114124f062223ca63d89b3006208489a492523efb875->doDisplay(Array, Array) (Line: 387)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 355)
Twig_Template->display(Array) (Line: 366)
Twig_Template->render(Array) (Line: 64)
twig_render_template('themes/custom/customtheme/templates/page.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('page', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 468)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 92)
__TwigTemplate_c9343766bf6adc2d3ee69a1ad1d87d0f76608c2a7ce17bb3255275241b160944->doDisplay(Array, Array) (Line: 387)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 355)
Twig_Template->display(Array) (Line: 366)
Twig_Template->render(Array) (Line: 64)
twig_render_template('themes/custom/customtheme/templates/html.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 147)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 148)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 149)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 98)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 77)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 628)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)