Fix <ds-search> rendering an empty page when the search configuration request fails - #6111
Conversation
…figuration request fails SearchComponent derives searchSortOptions$ from SearchConfigurationService.getConfigurationSearchConfig(), which pipes through getAllSucceededRemoteDataPayload(). When that request fails the observable never emits, so the combineLatest in ngOnInit never fires and initialized$ stays false. Both @if branches in search.component.html are gated on initialized$, so the whole template is skipped and the page renders empty: not even ds-search-results, which already knows how to render an error, is created. Treat a failed configuration as "no sort options" so the component still initializes. PaginationService.getCurrentSort() already falls back to its default when handed an empty default sort, so the empty list is safe, and the outcome of the results request (results, empty state, or error) is what the user sees. This affects every ds-search instance whose configuration is not already cached. /search normally survives because the homepage caches the 'default' configuration, but /mydspace, /access-control/bulk-access and the item and collection mappers request their own configurations only on those pages, so a failure there leaves a blank page. Adds specs asserting the component still initializes, and still requests results, when the search configuration request fails.
|
@naomigassler could you please provide a self written short text that outlines
|
|
Hi @naomigassler, since this PR seems to have spun off from #5936 which was closed and based on your comment there, I lean towards closing this as well. However, if it stands separately from 5936 and you feel strongly about moving it forward, it would need a clear PR description with testing steps as @tinsch describes, and should also use the PR template and checklist before this could be reviewed. |
|
Hi @lgeggleston and @tinsch, After the resolution of #5936 I have looked into this patch more deeply. Here is what this patch is trying to accomplish. If for some reason (network glitch, etc) the search configuration request initiated by the user fails to reach the backend, there is currently no notification for the user. The search simply shows no results. This is particularly problematic when looking at /mydspace. The user might be led to believe that there are no items at all in the queue, and nothing is telling them that reloading the search would reveal what is there. This addresses specifically the configuration request. If the results request fails, existing code already renders "Error fetching search results". This situation can easily be reproduced as follows (it doesn't need #6111 to be implemented):
Before the fix: the content area is empty — no search form, no results, no empty state, no error message. Only the submission drag-and-drop zone remains, because that sits outside After the fix: the page renders and is usable, but with an empty sort dropdown, and results come back in the fallback To see the error state instead, add a second pattern The PR also carries two unit specs, so this can be checked with a checkout and One thing to decide on and possible change: when the configuration request fails, the patch substitutes defaults silently. The sort order changes and the sort dropdown is empty, but nothing says so. It may be better to render the error alongside the results rather than quietly degrading the /mydspace page. I updated the PR description with the testing steps using the PR template and checklist. |
This PR was developed with the help of an LLM. I also relied on an LLM to write the description below.
References
_No issue ticket — this was found while investigating #5936 and is filed on its own merits.
main.Description
<ds-search>renders nothing at all — no search form, no results, no empty state and no error — when its search-configuration request fails. The page looks like an empty repository. This PR lets the component initialise so its existing error handling can run.Instructions for Reviewers
getConfigurationSearchConfig()pipes throughgetAllSucceededRemoteDataPayload(), so a failed configuration request never emits.combineLatesttherefore never fires,initialized$staysfalse, and the whole<ds-search>template is skipped — including theds-errorblock thatsearch-results.componentalready has. The error handling is present; it is simply never constructed.List of changes in this PR:
search.component.ts— initialise the component when the search-configuration request fails, falling back to empty sort options, so the existing error and empty states can render.search.component.spec.ts— two specs covering error-versus-empty.How to test
1. Unit specs — no backend, no configuration required.
The two added specs in
search.component.spec.tscover the case directly.2. In a browser. This reproduces on unmodified
main; the patch is not needed to see the bug./mydspace.⚠ Not
/search—/searchdoes not issue this request at all, because the homepage has already cached thedefaultconfiguration./mydspaceusesworkspace, which has not been cached./access-control/bulk-accessalso reproduces it.*discover/search?configuration=*⚠ Use exactly that pattern.
*/discover/search*also blocks the HALendpoint-discovery request, which produces a different failure that
demonstrates nothing.
Before this PR: the content area is empty — no search form, no results, no
empty state, no error. Only the submission drag-and-drop zone remains, because that sits outside
<ds-search>. The Network panel shows nodiscover/search/objectsrequest at all: the component never gets far enough to ask for results.After this PR: the page renders and is usable — though with an empty sort
dropdown, and results in the fallback
dc.title,ASCorder rather than theconfigured
lastModified,DESC, because only the configuration request was blocked and the results request still succeeds.To see the error state, add a second blocking pattern
*discover/search/objects*. You then get "Error fetching search results"instead of a blank page.
Known limitation, and a question for reviewers
Some installations report a
400on this endpoint when the search fires beforeauthentication is attached ("An anonymous user cannot perform a workspace or workflow search"). Upstream already treats that as "no results" via
showError()'sstatusCode !== 400exemption, and this PR leaves that exemption intact. Our stack does not reproduce that 400, so we have shown that this change does not introduce a spurious error state — not that it handles that case correctly.Separately: when only the configuration request fails, this PR substitutes defaults silently — the sort order changes and the sort dropdown is empty, with nothing saying so. It may be better to render the error alongside the results rather than
degrading quietly. I do not have a settled view and would welcome yours.
Checklist
mainbranch of code.npm run lint— full-repo clean.npm run check-circ-deps.ds-errorcomponent and message.