Loading
fix: #3621936 Fix agent process crash from a bad bundle-filter scalar value
Summary
A scalar string from the LLM (e.g. {"value":"tags"}) instead of a keyed
map overrides a bundle (content type/vocabulary) filter's array-typed
default. Views' Bundle filter plugin does not validate this before
save(): Bundle::calculateDependencies() calls array_keys($this->value),
which throws a \TypeError - not an \Exception - when $this->value is
a string, crashing the whole PHP process rather than just the one tool
call.
Changes
src/Plugin/AiFunctionCall/UpdateViewHandlerOptions.php: wraps the handler save (setHandler()/mergeDefaults()/save()) intry/catch (\Throwable $e), deliberately wider than\Exceptionsince the real failure is a\TypeError. Returns a normal, readable tool result on failure instead of letting the error propagate.config/install/ai_agents.ai_agent.views_agent.yml: documents the correct keyed-map shape for bundle/type filters (plugin_id"bundle"), with an explicit warning against both the bare-string and plain-list mistakes.tests/src/Kernel/Plugin/AiFunctionCall/UpdateViewHandlerOptionsTest.php: addedtestScalarValueForBundleFilterDoesNotCrash().tests/src/Kernel/Integration/ConfigureBundleFilterTest.php(new): addedtestScalarValueIsRejected(), reproducing the same mistake through the real create-handler-then-update-it tool chain and confirming the rejected value was never saved.
Test plan
- Both new regression tests confirmed failing before the fix
(uncaught
\TypeError) and passing after. - Full suite passes on this branch in isolation: 11/11 tests, 97 assertions, across both test files, no failures.
-
phpcs --standard=Drupal,DrupalPracticeandphpstan analyse(module config, level 1) clean on all changed PHP files.
Closes #3621936
AI-Generated: Yes (Used Claude Code to identify the bug while testing the shipped Views Agent against a live LLM, trace the root cause to Drupal core's Bundle filter plugin, implement the fix, and write both regression tests.)