Skip to content

Conversation

@AndyButland
Copy link
Contributor

@AndyButland AndyButland commented Jan 7, 2026

Description

When updating a content type to add a composition and remove a property at the same time, if the composition has a property with the same alias as the one being removed, this is rejected with an InvalidCompositionException - as raised in #21298.

Having checked Umbraco 13, this wasn't the case there. You could carry out this operation. Data loss will occur - as the property is not the same given it has a new ID and isn't stored by alias. This is the case in 13 and in 17.

This PR allows the operation to succeed by passing the removed property aliases to AddContentType, which excludes them from the conflict check

Change Summary

  • Added new overload IContentTypeComposition.AddContentType(IContentTypeComposition contentType, string[] removedPropertyTypeAliases) .
  • Updated ContentTypeCompositionBase.AddContentType to accept removed property aliases and exclude them from conflict detection.
  • Updated ContentTypeEditingServiceBase.UpdateCompositions to calculate removed property aliases and pass them when adding compositions.
  • Added integration tests to verify the behaviour.

Testing

Integration tests Cannot_Add_Composition_With_Conflicting_Property_Type_Alias and Can_Add_Composition_With_Conflicting_Property_Type_Alias_When_Alias_Is_Being_Removed test verify the behaviour.

Manual testing steps:

  • Create a document type with a property.
  • Create a second document type with a property with the same alias.
  • Create a document based on the document type and populate the property.
  • Edit the second document type, remove the property defined on the type and add the first document type as a composition.
  • Save the document type and note the operation now succeeds without error.
  • Note that the document's property data is lost, but that the document is editable as expected.

…when property is being removed

When updating a content type to add a composition and remove a property at the same time,
if the composition has a property with the same alias as the one being removed, this was
previously rejected with an InvalidCompositionException. This change allows the operation
to succeed by passing the removed property aliases to AddContentType, which excludes them
from the conflict check.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copilot AI review requested due to automatic review settings January 7, 2026 11:59
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 enables content type updates that simultaneously add a composition and remove a property when both have the same property alias. Previously, this operation would fail with an InvalidCompositionException even though the conflicting property was being removed.

Key Changes:

  • Added overload for AddContentType that accepts property aliases marked for removal
  • Updated conflict detection to exclude properties that will be removed
  • Added helper method to calculate removed property aliases during updates

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/Umbraco.Core/Models/IContentTypeComposition.cs Adds new interface method overload with removedPropertyTypeAliases parameter and default implementation for backward compatibility
src/Umbraco.Core/Models/ContentTypeCompositionBase.cs Implements the new overload and refactors conflict detection logic to exclude properties marked for removal
src/Umbraco.Core/Services/ContentTypeEditing/ContentTypeEditingServiceBase.cs Integrates removed property tracking into composition updates via new GetRemovedPropertyAliases helper method
tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceTests.cs Adds integration tests for both conflict scenarios (with and without removal) and removes unused imports (redundant due to ImplicitUsings)

@AndyButland AndyButland changed the title Content types: Allow adding composition with clashing property alias when property is being removed Content types: Allow adding composition with clashing property alias when property is being removed (closes 21298) Jan 7, 2026
@AndyButland AndyButland changed the title Content types: Allow adding composition with clashing property alias when property is being removed (closes 21298) Content types: Allow adding composition with clashing property alias when property is being removed (closes #21298) Jan 7, 2026
@AndyButland
Copy link
Contributor Author

Closing in favour of #21527

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