fix: #3621943 Fix exposed filters saving with no identifier

Summary

Exposing a filter with {"exposed":true,"expose":{"label":"..."}} and no identifier saved with an empty expose.identifier, which Drupal core's own View::validate() rejects ("The identifier is required if the filter is exposed."). An exposed filter with no identifier has no usable query parameter and cannot actually be submitted.

Changes

  • src/Plugin/AiFunctionCall/UpdateViewHandlerOptions.php: after merging the LLM-supplied options with the handler's existing configuration, defaults expose.identifier to the handler's own field ID whenever the filter is exposed and no identifier was supplied - matching Drupal core's own default for a newly-exposed handler (FilterPluginBase::defaultExposeOptions()). An explicitly-supplied identifier is left untouched.
  • tests/src/Kernel/Plugin/AiFunctionCall/UpdateViewHandlerOptionsTest.php: added testExposingFilterWithoutIdentifierDefaultsToFieldId().

Test plan

  • New regression test testExposingFilterWithoutIdentifierDefaultsToFieldId confirmed failing before the fix (empty identifier, failed validate()) and passing after.
  • Full test file passes on this branch in isolation: 10/10 tests, 79 assertions, no failures.
  • phpcs --standard=Drupal,DrupalPractice and phpstan analyse (module config, level 1) clean on both changed PHP files.

Closes #3621943

AI-Generated: Yes (Used Claude Code to identify the bug while testing exposed-filter prompts against the shipped Views Agent, trace the root cause, implement the fix, and write the regression test.)

Merge request reports

Loading