umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
Other
4.49k stars 2.69k forks source link

Can't add property to list view if the name collides with a system name #13007

Open matthewcare opened 2 years ago

matthewcare commented 2 years ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

10.2.0-preview.70

Bug summary

You cannot add your own document properties to list views if the name of your property matches one of the system properties.

Specifics

System fields include

Whilst some of these are reserved terms, such as sort order, not all of them are. image

It's an unlikely event that someone would do this, and the solution is pretty simple (rename your custom property), however it does highlight that there are hardcoded strings in the codebase which are also allowed to be used as property alias' which could cause a lot of problems in the future.

Steps to reproduce

Add a property to a content type which has the same name as one of the system fields in list views. Add the system field to the list view, and then try to add you content type property. Note: some system field names are reserved and not able to be used as a property alias.

Expected result / actual result

No response

github-actions[bot] commented 2 years ago

Hi there @matthewcare!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

nul800sebastiaan commented 2 years ago

We definitely should have all of those covered!

The error is coming from here: https://github.com/umbraco/Umbraco-CMS/blob/e626fca2432582f052cb13654eedd9e60ef8723f/src/Umbraco.Web.BackOffice/ModelsBuilder/ContentTypeModelValidatorBase.cs#L73

So any properties on IPublishedContent should be covered, not sure which from that list you're missing? Maybe we need to add a few more properties from other classes, specifially email and userName would be coming from members I'd guess.

nul800sebastiaan commented 2 years ago

Ha, the code I linked to say one line above that: // TODO: There are probably more! - so yeah seems like we never really checked! We'd love some help with that though 👍

github-actions[bot] commented 2 years ago

Hi @matthewcare,

We're writing to let you know that we would love some help with this issue. We feel that this issue is ideal to flag for a community member to work on it. Once flagged here, folk looking for issues to work on will know to look at yours. Of course, please feel free work on this yourself ;-). If there are any changes to this status, we'll be sure to let you know.

For more information about issues and states, have a look at this blog post.

Thanks muchly, from your friendly Umbraco GitHub bot :-)

kjac commented 1 year ago

@matthewcare I have reproduced this as well.

I understand your proposed fix is to disallow the reserved aliases when creating new properties. However, it seems to me that this fix comes at a pretty high price - namely that you won't be able to add properties like "Owner" or "Email" to content types. This would also be a functional breaking change, as existing content types with properties like that would suddenly stop working (or at least become problematic to edit due to validation errors).

An alternative approach to this would be to mend the list view implementation - to make it able to distinguish explicitly between system and custom properties. This should be doable... however it does involve some additional complexity when it comes to sorting items in the list view. And there is also a matter of migrating existing list views that might be necessary for such an approach.

The issue is still marked as "up for grabs" and we'd still love some help here 😄