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

Umbraco.Tags built-in property value converter throws null reference exception #3954

Closed bsubasic closed 5 years ago

bsubasic commented 5 years ago

The tags property editor, added on existing document type, throws null reference exception on a published page reload after successfully running ModelsBuilder and building a project (as I do regulary without a problem).

tagspropertyvalueconverter

Reproduction

Bug summary

Error in built-in Tags property value converter, on newly added Tags property to an existing document type that already has published pages.

Specifics

Umbraco version 7.12.4 assembly: 1.0.6879.21982 (upgraded, not clean install) .NET framework 4.7.1 ModelsBuilder 3.0.10.102 Browser: tested only in Chrome Version 71.0.3578.80 (Official Build) (64-bit)

Steps to reproduce

  1. Add a new property of type Umbraco.Tags to some existing (published) page (content type)
  2. Name it "Tags", alias = "tags", create custom configuration with TagGroup = "blog" and StorageType = "Json"
  3. Run ModelsBuilder via API custom tool configuration and verify generated Tags property
        ///<summary>
        /// Tags: Set article tags
        ///</summary>
        [ImplementPropertyType("tags")]
        public IEnumerable<string> Tags
        {
            get { return this.GetPropertyValue<IEnumerable<string>>("tags"); }
        }
  4. Create simple razor code where you can check for Tags property value (simple if clause)
  5. Build the project
  6. Reload some existing page of the content type where you have added the new Tags property
  7. It throws an unhandled exception during the Tags property value conversion

Expected result

I would expect that this new property doesn't have any value (tags) on existing pages where it applies and to return empty string array or even null.

Actual result

It throws an unhandled exception during the property value conversion.

I tried to republish the page/s after adding tags property, nothing happened - the same error appeared. I tried to preview the page/s after adding tags property, and after previewing it and reloading the page URL - error disappeared and I got expected result - empty string array of tags property.

This was weird, I don't know what is going on in the background with previewing the page but it works after. And that needs to be done for each existing page of the mentioned content type in order to be able to display the page without the error.

kjac commented 5 years ago

I can reproduce this. PR on its way.

kjac commented 5 years ago

PR in #3963