dspace-angular icon indicating copy to clipboard operation
dspace-angular copied to clipboard

Return not found status code on missing identifiers

Open jensvannerum opened this issue 1 year ago • 3 comments

References

Add references/links to any related issues or PRs. These may include:

  • Fixes #2817

Description

This change makes sure the correct status code is returned for pages related to missing identifiers

Instructions for Reviewers

This PR simply uses the ServerResponseService to set the correct status code on initialisation of the component..

Testing this is possible by sending a curl request to the issues mentioned in the original issue:

  • curl --head {ui-url}/handle/{non-existing-handle}/browse
  • curl --head {ui-url}/handle/{non-existing-handle}/search-filter

And verify 404 is returned instead of 200

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You need not complete this checklist prior to creating your PR (draft PRs are always welcome). If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • [x] My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • [x] My PR passes ESLint validation using yarn lint
  • [x] My PR doesn't introduce circular dependencies (verified via yarn check-circ-deps)
  • [x] My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • [x] My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • [x] If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • [x] If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • [x] If my PR fixes an issue ticket, I've linked them together.

jensvannerum avatar Feb 19 '24 13:02 jensvannerum

Thanks @jensvannerum. I tested this on localhost with DSpace 7.6.2-SNAPSHOT (note that the frontend must be built in production mode) and it works.

I checked a variety of URLs that were previously returning HTTP 200 incorrectly:

$ curl --head localhost:4000/handle/foo/bar
HTTP/1.1 404 Not found
$ curl --head localhost:4000/handle/10568/3  <--- this exists, and is expected to redirect
HTTP/1.1 301 Moved Permanently
$ curl --head localhost:4000/handle/10568/3/browse
HTTP/1.1 404 Not found
$ curl --head localhost:4000/handle/10000000/093991991
HTTP/1.1 404 Not found

I will let someone else review the code.

alanorth avatar Feb 23 '24 11:02 alanorth

Hi @jensvannerum, Conflicts have been detected against the base branch. Please resolve these conflicts as soon as you can. Thanks!

github-actions[bot] avatar Mar 08 '24 15:03 github-actions[bot]

Hi @jensvannerum, Conflicts have been detected against the base branch. Please resolve these conflicts as soon as you can. Thanks!

github-actions[bot] avatar Mar 20 '24 14:03 github-actions[bot]

Backport failed for dspace-7_x, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin dspace-7_x
git worktree add -d .worktree/backport-2816-to-dspace-7_x origin/dspace-7_x
cd .worktree/backport-2816-to-dspace-7_x
git switch --create backport-2816-to-dspace-7_x
git cherry-pick -x ab90c7a733e575c9a75407be549d124bff49fd48 f9c8103266f7ca392356be92107d0e9d8bb7f89c

dspace-bot avatar Apr 19 '24 17:04 dspace-bot

Manually ported to dspace-7_x in #2965

tdonohue avatar Apr 19 '24 17:04 tdonohue