Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return 404 Not Found status code on missing identifiers #2816

Merged

Conversation

jensvannerum
Copy link
Contributor

@jensvannerum jensvannerum commented Feb 19, 2024

References

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

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!

  • 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.
  • My PR passes ESLint validation using yarn lint
  • My PR doesn't introduce circular dependencies (verified via yarn check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • 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.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

@jensvannerum jensvannerum force-pushed the w2p-111326_fix-status-code-object-not-found-7.4 branch from 8241a66 to 26ace07 Compare February 19, 2024 13:18
@jensvannerum jensvannerum changed the title 111326: return not found status code on missing identifiers Return not found status code on missing identifiers Feb 19, 2024
@tdonohue tdonohue added bug component: SEO Search Engine Optimization 1 APPROVAL pull request only requires a single approval to merge port to dspace-7_x This PR needs to be ported to `dspace-7_x` branch for next bug-fix release labels Feb 20, 2024
@jensvannerum jensvannerum force-pushed the w2p-111326_fix-status-code-object-not-found-7.4 branch from 26ace07 to ab90c7a Compare February 21, 2024 14:41
@alanorth
Copy link
Contributor

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.

Copy link

github-actions bot commented Mar 8, 2024

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

Copy link

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

@tdonohue tdonohue self-requested a review March 28, 2024 15:53
@tdonohue tdonohue added this to the 8.0 milestone Apr 19, 2024
@tdonohue tdonohue changed the title Return not found status code on missing identifiers Return 404 Not Found status code on missing identifiers Apr 19, 2024
Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks @jensvannerum ! I've verified this works and it fixes the bug where some of these "not found" URLs were returning 200 OK

@tdonohue tdonohue merged commit 6d582cd into DSpace:main Apr 19, 2024
13 checks passed
@dspace-bot
Copy link
Contributor

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

@tdonohue
Copy link
Member

Manually ported to dspace-7_x in #2965

@tdonohue tdonohue removed the port to dspace-7_x This PR needs to be ported to `dspace-7_x` branch for next bug-fix release label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 APPROVAL pull request only requires a single approval to merge bug component: SEO Search Engine Optimization
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

200 Status codes are returned for pages with non-resolving identifiers
4 participants