-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Management API: Return not found from request for content references when entity does not exist (closes #20997) #20999
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
base: main
Are you sure you want to change the base?
Management API: Return not found from request for content references when entity does not exist (closes #20997) #20999
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a regression in the Management API where reference endpoints (ReferencedBy and ReferencedDescendants) would return all items instead of a 404 Not Found response when an invalid entity ID was provided. The change adds entity existence validation using IEntityService before processing reference queries.
Key changes:
- Added 404 Not Found validation for all reference endpoints across Document, Media, and Member controllers
- Introduced IEntityService dependency injection with backward-compatible obsolete constructors
- Added ProducesResponseType attributes documenting the new 404 responses
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| ReferencedDescendantsMemberController.cs | Added entity validation to return 404 for non-existent member IDs |
| ReferencedByMemberController.cs | Added entity validation to return 404 for non-existent member IDs |
| ReferencedDescendantsMediaController.cs | Added entity validation to return 404 for non-existent media IDs |
| ReferencedByMediaController.cs | Added entity validation to return 404 for non-existent media IDs |
| ReferencedDescendantsDocumentController.cs | Added entity validation to return 404 for non-existent document IDs |
| ReferencedByDocumentController.cs | Added entity validation to return 404 for non-existent document IDs |
...co.Cms.Api.Management/Controllers/Member/References/ReferencedDescendantsMemberController.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Cms.Api.Management/Controllers/Member/References/ReferencedByMemberController.cs
Outdated
Show resolved
Hide resolved
...raco.Cms.Api.Management/Controllers/Media/References/ReferencedDescendantsMediaController.cs
Outdated
Show resolved
Hide resolved
...raco.Cms.Api.Management/Controllers/Media/References/ReferencedDescendantsMediaController.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Cms.Api.Management/Controllers/Media/References/ReferencedByMediaController.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Cms.Api.Management/Controllers/Media/References/ReferencedByMediaController.cs
Outdated
Show resolved
Hide resolved
...ms.Api.Management/Controllers/Document/References/ReferencedDescendantsDocumentController.cs
Outdated
Show resolved
Hide resolved
...Umbraco.Cms.Api.Management/Controllers/Document/References/ReferencedByDocumentController.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Prerequisites
Addresses: #20997
Description
Between 16 and 17 it is reported that these reference endpoints would return all items instead of an empty collection when the provided ID was not recognised. It seems better really that these would return "not found", which is what I've done in this PR.
Testing
Using the management API, make requests to e.g.
umbraco/management/api/v1/media/{id}/referenced-descendantsand verify that providing an ID that doesn't exist, or isn't of the right type, returns a 404 response.