Umbraco-CMS: Umbraco 14 RC 3 - Method CreateBlockModel.EnrichBlockItem cannot create a BlockGridModel
Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)
14.0.0-rc3
Bug summary
The persisted Json from a simple blockgrid without any custom configuration generates json that isn’t compatible with the CreateBlockModel -> EnrichBlockItem method in BlockGridPropertyValueCreator.cs
The result is an exception whenever you try to render a blockgrid through MVC or Content Delivery Api
Specifics
On a completly fresh Umbraco 14 installation with nothing but a page with a blockgrid and a single element in that blockgrid
This code:
@using Umbraco.Cms.Web.Common.PublishedModels;
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Page>
@{
Layout = null;
var test = Model.Grid;
}
Will give the following exception
InvalidOperationException: Nullable object must have a value.
System.Nullable<T>.get_Value()
Umbraco.Cms.Core.PropertyEditors.ValueConverters.BlockGridPropertyValueCreator+<>c__DisplayClass3_0.<CreateBlockModel>g__EnrichBlockItem|2(BlockGridItem blockItem, BlockGridLayoutItem layoutItem, BlockGridBlockConfiguration blockConfig, CreateBlockItemModelFromLayout createBlockItem) in BlockGridPropertyValueCreator.cs
+
blockItem.RowSpan = layoutItem.RowSpan!.Value;
To be able to continue my work I’ve done the following in Umbraco.Cms.Core.PropertyEditors.ValueConverters.BlockGridPropertyValueConverter:
Replaced this line “blockItem.RowSpan = layoutItem.RowSpan!.Value;” with “blockItem.RowSpan = layoutItem.RowSpan ?? 0;”
I have commented out the offending line and written a fallback. But I have a feeling this isn’t the correct solution. I’m guessing it’s on purpose that we expect the model to have a value and that it’s an error in how the json for the blockgrid is generated on save.
I’d happily pull request this in, but as noted, I expect that the issue is deeper and that it should be handled at the source instead of having a fallback here.
Steps to reproduce
Create new Umbraco 14 site with RC3
Create Document Type with Template called Page - set allow as root node Create Element Type called Element Create Blockgrid on Page, add Element as a block and allow in root.
Create content “Home”, add an element to the grid and attempt to output the grid, in any way in MVC.
Ie.
@using Umbraco.Cms.Web.Common.PublishedModels;
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Page>
@{
Layout = null;
var test = Model.Grid;
}
Expected result / actual result
I’d expect to be able to access my blockgrid.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 18 (17 by maintainers)
Hi @kasparboelkjeldsen
Edit: forget what i wrote here, I made a human mistake, simply got a wrong version.
I just concluded there is something off with our build, the RC does not contain the files we expected.Both an issue with files not begin bundles, which we started doing a bit for 14.1, as well we see polyfills for private fields setters, which we should not.I have handed the task over to the DevOps people.Can confirm - works when live editing mode is disabled
I can reproduce this one, unfortunately it also stops the content deliver API cold in it’s tracks.
I’m guessing it must be some kind of value convertor issue since the backoffice saves and retrieves the values on the node just fine.