Relations: Allow Element and ElementContainer as allowed object types for relation creation#23217
Conversation
|
Claude finished @ronaldbarendse's task in 2m 45s —— View job PR ReviewTarget: Adds
No Critical or Important issues found. No breaking changes — the change is purely additive. Suggestions
ApprovedThe fix is minimal, targeted, and correct. The two new integration test cases directly mirror the seeded relation types introduced in |
There was a problem hiding this comment.
Pull request overview
This PR fixes a validation gap in IRelationService by allowing the new v18 element object types (Element, ElementContainer) to be used when creating/updating relation types via RelationService, aligning service validation with the relation types seeded by install/migrations.
Changes:
- Extend
RelationService.GetAllowedObjectTypes()to includeUmbracoObjectTypes.ElementandUmbracoObjectTypes.ElementContainer. - Expand integration test coverage to assert relation types can be created with
ElementContainer → ElementandElementContainer → ElementContainerobject type combinations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Umbraco.Core/Services/RelationService.cs | Adds Element/ElementContainer to the allowed object type set used by relation type validation. |
| tests/Umbraco.Tests.Integration/Umbraco.Core/Services/RelationServiceTests.cs | Adds two integration test cases covering the newly-allowed element relation type combinations. |
|
There was a problem hiding this comment.
Thanks @ronaldbarendse, looks good and a clear oversight/fix.
I'll label this for 18.1 for now, as it'll definitely be in that, but likely bring forward to 18.0.1 if and when we arrange a patch release.
Element and ElementContainer as allowed object types for relation creation
…ypes for relation creation (umbraco#23217) Allow Element and ElementContainer object types in RelationService



Prerequisites
If there's an existing issue for this PR then this fixes #23216
Description
v18 seeds three built-in element relation types (parent/child object types
Element/ElementContainer) directly into the database viaDatabaseDataCreator(install) and theV_18_0_0.AddElementsmigration (upgrade), bypassingIRelationService. ButRelationService.SaveAsyncvalidates object types againstGetAllowedObjectTypes(), which never hadElement/ElementContaineradded. As a result the service rejects anyCreateAsync/UpdateAsyncof these relation types withInvalidParentObjectType/InvalidChildObjectType— breaking the backoffice Relations list and Umbraco Deploy import/transfer (which re-saves built-in relation types through the service).This adds
ElementandElementContainertoGetAllowedObjectTypes().How to test:
IRelationService, loadrelateParentElementContainerOnElementDeleteviaGetRelationTypeByAlias, and callUpdateAsync— it now returnsRelationTypeOperationStatus.Success(previouslyInvalidParentObjectType).Can_Create_Relation_Types_With_Allowed_Object_Typesnow coversElementContainer→ElementandElementContainer→ElementContainer.Changes:
src/Umbraco.Core/Services/RelationService.cs— addUmbracoObjectTypes.ElementandUmbracoObjectTypes.ElementContainerto the allowed set.tests/Umbraco.Tests.Integration/.../RelationServiceTests.cs— two new test cases.