Skip to content

Commit c3a1086

Browse files
milanmajchrakclaude
andcommitted
TUL/fix: default filter operator to 'equals' for operator-less URLs (#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>
1 parent 5e1de44 commit c3a1086

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/app/core/shared/search/search-configuration.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('SearchConfigurationService', () => {
3131
});
3232

3333
const backendFilters = [
34-
new SearchFilter('f.author', ['another value']),
34+
new SearchFilter('f.author', ['another value'], 'equals'),
3535
new SearchFilter('f.date', ['[2013 TO 2018]'], 'equals')
3636
];
3737

src/app/core/shared/search/search-configuration.service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ export class SearchConfigurationService implements OnDestroy {
196196
filters.push(new SearchFilter(realKey, ['[' + min + ' TO ' + max + ']'], 'equals'));
197197
}
198198
} else {
199-
filters.push(new SearchFilter(key, filterParams[key]));
199+
// Default to the "equals" operator when a filter value carries none (e.g. a legacy or
200+
// crawled URL like "f.subject=foo" instead of "f.subject=foo,equals"). Without this the
201+
// backend rejects the operator-less filter with HTTP 422. Values that already embed an
202+
// operator (contain a comma) keep it - see SearchOptions.toRestUrl. dspace-customers#781.
203+
filters.push(new SearchFilter(key, filterParams[key], 'equals'));
200204
}
201205
});
202206
return filters;

src/app/my-dspace-page/my-dspace-configuration.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('MyDSpaceConfigurationService', () => {
3030
});
3131

3232
const backendFilters = [
33-
new SearchFilter('f.namedresourcetype', ['another value']),
33+
new SearchFilter('f.namedresourcetype', ['another value'], 'equals'),
3434
new SearchFilter('f.dateSubmitted', ['[2013 TO 2018]'], 'equals')
3535
];
3636

0 commit comments

Comments
 (0)