Prevent NPE in MyData when all dataverses are harvested dataverses #11086
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
As discussed in #11083, MyData was checking for empty results and then filtering against harvested dataverses, producing a NullPointerException later on when all the results are harvested dataverses.
This moves the empty results check after filtering against harvested dataverses, resulting in a 'Sorry, no results were found." API response instead of the previous server error.
Which issue(s) this PR closes:
This improves #11083 but does not close it (non-harvested datasets in harvested dataverses are still filtered).
Special notes for your reviewer:
See the issue for steps to reproduce.
Suggestions on how to test this:
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
No interface change
Is there a release notes update needed for this change?:
This could be mentioned (see snippet) but has no major impact.
Additional documentation:
I updated the IT test with some extra use cases. I'm not actually testing the harvested dataverse case as I am not sure if the expected result is truly the same as the current result.
Bug mentioned at https://dataverse-guide--11086.org.readthedocs.build/en/11086/api/native-api.html#mydata