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 instead of 500 when an "original parent" has been deleted #15990

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

kjac
Copy link
Contributor

@kjac kjac commented Apr 4, 2024

Prerequisites

  • I have added steps to test this contribution in the description below

Description

The API explicitly returns a 500 response code if the "original parent" of a "restore from recycle bin" attempt is not found:

image

This seems very dramatic 😄 specially since this is a normal, expected scenario; the "original parent" has simply been deleted from the recycle bin, before the attempt to restore the previous child is made.

This PR changes the response code to be a 404 instead. Less dramatic 😛

image

Testing this PR

  1. Create a parent and a child document.
  2. Move the child to the recycle bin.
  3. Delete the parent entirely.
  4. Request the "original parent" from /umbraco/management/api/v1/recycle-bin/document/{key}/original-parent.
  5. Verify that a 404 is returned.

Rinse and repeat for media.

Note that "move to recycle bin" and "delete" operations are currently only functional through the API (in other words, use Swagger).

Copy link
Contributor

@Migaroez Migaroez left a comment

Choose a reason for hiding this comment

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

It took me a while to follow your train of thought, but you are right. There is a reasonable course where the relation would not exists (cleanup of relation because parent was fully deleted).

@kjac kjac merged commit c6f1189 into v14/dev Apr 5, 2024
17 checks passed
@kjac kjac deleted the v14/recycle-bin-restore-error-less-dramatic branch April 5, 2024 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants