question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Indexing fails for date conversion

See original GitHub issue

Which 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:closed
  • Created 4 months ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
SATC-Bencommented, May 31, 2023

Right, thanks for that. I’ve done some digging and found the following:

  • The issue we are seeing appears to be in NestedContentItems that use DatePickers
  • During our upgrade from 8 to 11 we haven’t changed the format of the dates that are having the issue. I confirmed this from looking in the database and checking the usync files from pre/post-upgrade.
    • Screenshot 2023-06-01 073756
    • DB [umbracoDataType] same for both V8 & V11.4.0 (Img attached)
    • Screenshot 2023-06-01 074543
    • Usync comparison for V8 & V11.4.0 (Img attached)
  • Attempting to publish again made no change, unfortunately. The following was taken from the database:
    • Pre-Publish: \"toDate\": \"8/31/2022 12:00:00 AM\",\r\n
    • Post-Publish: \"toDate\": \"8/31/2022 12:00:00 AM\",\r\n

So there are a few things that would be helpful to know with this:

  • What sets the date format of what is stored in a NestedContentItem? It doesn’t appear to have ever been the DatePicker format. – Is it the global language that influences this? Ours is set to En-US
  • What has changed between version V11.1.0 to V11.3.1 that has caused the indexing system to not account for the date format that’s used in NestedContentItems?
0reactions
andr317ccommented, Jun 7, 2023

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 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to convert index to date format - python
Assuming your input is a string, simply converting the / to - won't fix the issue. The real problem is that you've told...
Read more >
Floating-point value accepted for a date field during ...
Floating-point values are accepted into a date field during initial document insert, but cause later update/re-index operations to fail.
Read more >
Indexing fails with timestamp conversion MySQL error
The issue happens due to zero dates values "0000-00-00 00:00:00" that cannot be converted to timestamp from the JDBC.
Read more >
Reindexing string to date format error - Elasticsearch
Hello, I'm trying to reindex my data because of mapping changes and in this process I´m trying to convert a string to date...
Read more >
Issue with date format change while reindexing
I have a change in the format of date field from "yyyy-mm-ddThh:mm:ss. ... the following error while reindexing my data to a new...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found