TUL/fix: default filter operator to 'equals' for operator-less search URLs (#781) - #1368
TUL/fix: default filter operator to 'equals' for operator-less search URLs (#781)#1368milanmajchrak wants to merge 2 commits into
Conversation
…781) A search URL whose filter carries no operator (e.g. a legacy or crawled "/search?f.subject=foo" instead of "f.subject=foo,equals") was forwarded to the backend verbatim. The backend correctly rejects the operator-less filter with HTTP 422 per the DSpace REST Contract, producing an error on every affected search render (dataquest-dev/dspace-customers#781). When reading active filters from the URL in SearchConfigurationService. getCurrentFilters, default the operator to 'equals' (mirroring the existing range-filter branch). Values that already embed an operator - i.e. contain a comma - are left untouched by SearchOptions.toRestUrl, so explicit operators (equals/notequals/contains/authority/...) are preserved. Operator-less legacy URLs now resolve to "<value>,equals" and return results instead of 422. Updated the getCurrentFilters expectations in the SearchConfigurationService and MyDSpaceConfigurationService specs accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent legacy/crawled search URLs with operator-less filters (e.g. f.subject=foo) from being forwarded to the REST backend without an operator, which currently triggers HTTP 422 responses and cascades into multiple failing discover requests per page render.
Changes:
- Default non-range URL-derived
SearchFilteroperators to'equals'inSearchConfigurationService.getCurrentFilters(). - Update unit test expectations so non-range filters created from URL params include
operator: 'equals'. - Keep range filter handling (
.min/.max) unchanged (already uses'equals').
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/app/core/shared/search/search-configuration.service.ts | Defaults operator to 'equals' when converting URL filter params to SearchFilters. |
| src/app/core/shared/search/search-configuration.service.spec.ts | Adjusts getCurrentFilters expectations for the default operator behavior. |
| src/app/my-dspace-page/my-dspace-configuration.service.spec.ts | Updates MyDSpace filter expectations to include the default operator. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Previously getCurrentFilters set operator='equals' on every non-range filter, even when the URL value already embedded an operator (e.g. "foo,contains"), which could confuse consumers reading filter.operator directly (e.g. CSV export). Now default to 'equals' only when no value carries an operator suffix (contains a comma), matching SearchOptions.toRestUrl. Added a spec fixture for an operator-embedded value asserting the operator stays unset. Per Copilot review on #1368. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Problem
A search URL whose filter carries no operator — e.g. a legacy or crawled
/search?f.subject=radiodiagnostikainstead off.subject=radiodiagnostika,equals— is forwarded to the backend verbatim. The backend correctly rejects the operator-less filter with HTTP 422 per the DSpace REST Contract, and because one search page fans out into ~6 discover sub-requests (search/objects + each facet), each affected render produces a burst of 422s (dataquest-dev/dspace-customers#781).Today's UI always emits
,equalson facet links, so these operator-less URLs are legacy/bookmarked/crawled links from before the operator format.Fix
In
SearchConfigurationService.getCurrentFilters(), when buildingSearchFilters from the URL, default the operator to'equals'— mirroring the existing range-filter (.min/.max) branch right above, which already passes'equals'.This is safe because
SearchOptions.toRestUrlonly appends the operator when the value does not already contain a comma:So values that already embed an operator (
radiodiagnostika,equals,foo,notequals,id,authority, …) are left untouched; only truly operator-less values gain,equals. Operator-less legacy URLs now resolve to<value>,equalsand return results instead of 422.Tests
Updated the
getCurrentFiltersexpectations insearch-configuration.service.spec.tsandmy-dspace-configuration.service.spec.ts(the plain, non-range filter now carriesoperator: 'equals').Companion
A backend PR (dataquest-dev/DSpace customer/TUL) downgrades any remaining discover 422 from ERROR to WARN so monitoring is not tripped even if an operator-less request slips through another path.