Skip to content

fix(#3376193): use filter identifier when building preview URL - #13

Open
Decipher wants to merge 2 commits into
8.x-1.xfrom
feature/3376193-preview-filter-identifier
Open

fix(#3376193): use filter identifier when building preview URL#13
Decipher wants to merge 2 commits into
8.x-1.xfrom
feature/3376193-preview-filter-identifier

Conversation

@Decipher

@Decipher Decipher commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Fixes #3376193.

Problem

jsonapi_views_views_preview_info_alter() keyed the exposed-input
lookup by filter field name. Views stores exposed input keyed by the
filter's identifier, which defaults to the field name but can differ.

When the identifier differs from the field name, the lookup hit an
undefined key. This logged a PHP warning on every preview and dropped
the filter from the previewed JSON:API Views URL.

Fix

Read each filter's identifier from $filter->options['expose']['identifier'],
fall back to $filter->field for the common case, and guard the array
access with isset().

Credits

Tests

Kernel coverage added. The test view already has a filter whose
identifier (content_type) differs from its field name (type), so the
test reproduces the bug directly. It fails with Undefined array key "type" on unfixed code and passes after the fix.

Related

#3277489 is a duplicate report with a different approach and is already
closed.

Summary by CodeRabbit

  • Bug Fixes
    • Improved exposed filter links to use each filter’s configured identifier.
    • Prevented non-exposed filters and filters without valid identifiers from appearing in query parameters.
    • Ensured filter values are included only when their configured identifiers are present.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 70a37d5e-06de-49dc-aeeb-a52ba15c147b

📥 Commits

Reviewing files that changed from the base of the PR and between 3e50d79 and bf3fc9b.

📒 Files selected for processing (2)
  • jsonapi_views.module
  • tests/src/Kernel/JsonapiViewsResourceKernelTest.php

📝 Walkthrough

Walkthrough

The filter preview query now skips non-exposed filters, uses configured exposed identifiers, and includes values only when those identifiers exist. A kernel test verifies identifiers that differ from field names.

Changes

Exposed filter identifiers

Layer / File(s) Summary
Filter query construction and preview validation
jsonapi_views.module, tests/src/Kernel/JsonapiViewsResourceKernelTest.php
The query builder skips non-exposed filters and uses each configured exposed identifier or field fallback. The kernel test verifies both identifiers and excludes the field-name key type.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: using the filter identifier when building the preview URL.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/3376193-preview-filter-identifier

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.11%. Comparing base (3e50d79) to head (bf3fc9b).

Additional details and impacted files
@@           Coverage Diff            @@
##           8.x-1.x      #13   +/-   ##
========================================
  Coverage    94.11%   94.11%           
========================================
  Files            3        3           
  Lines          136      136           
========================================
  Hits           128      128           
  Misses           8        8           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant