Skip to content

Conversation

@AndyButland
Copy link
Contributor

Prerequisites

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

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-descendants and verify that providing an ID that doesn't exist, or isn't of the right type, returns a 404 response.

Copilot AI review requested due to automatic review settings November 28, 2025 15:34
@AndyButland AndyButland changed the title Management API: Return not found from request for content references when entity does not exist Management API: Return not found from request for content references when entity does not exist (closes #20997) Nov 28, 2025
Copilot finished reviewing on behalf of AndyButland November 28, 2025 15:36
Copy link
Contributor

Copilot AI left a 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-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants