Indexing fails for date conversion
See original GitHub issueWhich Umbraco version are you using? (Please write the exact version, example: 10.1.0)
11.4.0
Specifics
Hi, We updated from 11.1.0 to 11.3.1 and started getting this issue when the index builds. I then saw #14096
and updated it to 11.4.0 but got the same results. For context, we use the default language (en-US) but are situated in Australia with dd/mm/yyyy formats.
[13:43:15 ERR] Error occurred executing workItem. System.InvalidOperationException: Cannot assign value "8/31/2022 12:00:00 AM" of type "System.String" to property "toDate" expecting type "System.DateTime". at Umbraco.Cms.Core.Models.Property.ThrowTypeException(Object value, Type expected, String alias) at Umbraco.Cms.Core.Models.Property.TryConvertAssignedValue(Object value, Boolean throwOnError, Object& converted) at Umbraco.Cms.Core.Models.Property.SetValue(Object value, String culture, String segment) at Umbraco.Cms.Core.PropertyEditors.NestedPropertyIndexValueFactoryBase2.GetNestedResults(String keyPrefix, String culture, String segment, Boolean published, IDictionary2 propertyTypeDictionary, TItem nestedContentRowValue, IEnumerable1 availableCultures)+MoveNext() at System.Collections.Generic.List1.InsertRange(Int32 index, IEnumerable1 collection) at Umbraco.Cms.Core.PropertyEditors.NestedPropertyIndexValueFactoryBase2.Handle(TSerialized deserializedPropertyValue, IProperty property, String culture, String segment, Boolean published, IEnumerable1 availableCultures) at Umbraco.Cms.Core.PropertyEditors.JsonPropertyIndexValueFactoryBase1.GetIndexValues(IProperty property, String culture, String segment, Boolean published, IEnumerable1 availableCultures) at Umbraco.Cms.Core.PropertyEditors.NestedPropertyIndexValueFactoryBase2.GetNestedResults(String keyPrefix, String culture, String segment, Boolean published, IDictionary2 propertyTypeDictionary, TItem nestedContentRowValue, IEnumerable1 availableCultures)+MoveNext() at System.Collections.Generic.List1.InsertRange(Int32 index, IEnumerable1 collection) at Umbraco.Cms.Core.PropertyEditors.NestedPropertyIndexValueFactoryBase2.Handle(TSerialized deserializedPropertyValue, IProperty property, String culture, String segment, Boolean published, IEnumerable1 availableCultures) at Umbraco.Cms.Core.PropertyEditors.JsonPropertyIndexValueFactoryBase1.GetIndexValues(IProperty property, String culture, String segment, Boolean published, IEnumerable1 availableCultures) at Umbraco.Cms.Infrastructure.Examine.BaseValueSetBuilder1.AddPropertyValue(IProperty property, String culture, String segment, IDictionary2 values, IEnumerable1 availableCultures) at Umbraco.Cms.Infrastructure.Examine.ContentValueSetBuilder.GetValueSetsEnumerable(IContent[] content, Dictionary2 creatorIds, Dictionary2 writerIds)+MoveNext() at System.Collections.Generic.LargeArrayBuilder1.AddRange(IEnumerable1 items) at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable1 source) at Umbraco.Cms.Infrastructure.Examine.ContentIndexPopulator.IndexPublishedContent(Int32 contentParentId, Int32 pageIndex, Int32 pageSize, IReadOnlyList1 indexes) at Umbraco.Cms.Infrastructure.Examine.ContentIndexPopulator.PopulateIndexes(IReadOnlyList1 indexes) at Umbraco.Cms.Infrastructure.Examine.IndexPopulator.Populate(IIndex[] indexes) at Umbraco.Cms.Infrastructure.Examine.ExamineIndexRebuilder.RebuildIndex(String indexName, TimeSpan delay, CancellationToken cancellationToken) at Umbraco.Cms.Infrastructure.Examine.ExamineIndexRebuilder.<>c__DisplayClass9_1.b__1() at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Umbraco.Cms.Infrastructure.HostedServices.QueuedHostedService.BackgroundProcessing(CancellationToken stoppingToken)
Steps to reproduce
Settings > Examine Management > ExternalIndex > Rebuild index
Expected result / actual result
Expected: Index runs without issue.
Actual: After a while …
The process is taking longer than expected, check the Umbraco log to see if there have been any errors during this operation
also the error in the log mentioned above.
Issue Analytics
- State:
- Created 4 months ago
- Reactions:1
- Comments:9 (4 by maintainers)
Right, thanks for that. I’ve done some digging and found the following:
NestedContentItems
that useDatePickers
\"toDate\": \"8/31/2022 12:00:00 AM\",\r\n
\"toDate\": \"8/31/2022 12:00:00 AM\",\r\n
So there are a few things that would be helpful to know with this:
NestedContentItem
? It doesn’t appear to have ever been the DatePicker format. – Is it the global language that influences this? Ours is set toEn-US
NestedContentItems
?Hey!
I just took a look at this issue, and what I can see is that you are using the default Date Picker Format which is YYYY-MM-DD, for the Australian time. But the date you are inserting into the Date Picker is in the format of MM-DD-YYYY HH:mm:ss A. The error you get is because the formats are not the same.
To fix this, I will recommend creating another DatePicker DataType which has the date format: MM-DD-YYYY HH:mm:ss A.
It’s very likely that this problem was hiding there all along, however, up until 10.3 the contents of the block list and block grid were not indexed properly, so that would be why it worked before, since the data wasn’t processed in the indexer.
Since there is no issue with the Date Picker, I will go ahead and close this issue. Please feel free to comment if this fix does not work! Then we can have another look 😄