umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.41k stars 2.66k forks source link

Error when using a multiple contentpickers with differing idType configs #10951

Closed mattbrailsford closed 2 years ago

mattbrailsford commented 3 years ago

Which exact Umbraco version are you using? For example: 8.13.1 - don't just write v8

v9 RC2

Bug summary

When using content pickers, they can have a config passed that sets it's idType whether it picks ints or udis. There is currently a bug however that if you have multiple content pickers that are configured differently anywhere on the site, the first content picker will work, but when you pick an item in the second picker, you get an error.

Specifics

I believe some kind of caching must be going on and there is an assumption that the idType is always the same and so some error is thrown when this is not the case

An error occurred
Error converting value "1070" to type 'Umbraco.Cms.Core.Udi'. Path 'ids[0]'.

Exception Details
Newtonsoft.Json.JsonSerializationException, Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed: Error converting value "1070" to type 'Umbraco.Cms.Core.Udi'. Path 'ids[0]'.
Stacktrace
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
   at Umbraco.Cms.Web.BackOffice.ModelBinders.FromJsonPathAttribute.JsonPathBinder.BindModelAsync(ModelBindingContext bindingContext)
   at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinder.BindModelAsync(ModelBindingContext bindingContext)
   at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value, Object container)
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

Steps to reproduce

Create multiple properties of type contentpicker, one with idType of int the other with udi Pick an item in one of the pickers then close it Pick an item in the other picker and you'll get the YSOD

Expected result / actual result

I'd expect both to be able to pick content


_This item has been added to our backlog AB#13524_

nikolajlauridsen commented 3 years ago

Hey @mattbrailsford, this is a bit embarrassing, but I have to admit I'm not sure what you mean when you say "Create multiple properties of type contentpicker, one with idType of int the other with udi", when creating a contentpicker in the backoffice there is no such option, only "Show open button", "Start node", and "Ignore User Start Nodes".

Can you elaborate a bit about how you set up the contentpicker with a specific idType so I can reproduce? šŸ˜„

bergmania commented 2 years ago

Hi @mattbrailsford.. Can you help us here, so we are sure how to reproduce?

bergmania commented 2 years ago

Closing this for now but we can have another look if you have more details for us

kindbergco commented 2 years ago

Hi team,

I also got this issue. Basically it's from a macro, where I use a multinodetreepicker to select nodes to render in the macro. it was working perfectly on v8, however on v9, I get the below. I really have not seen any steps to "recreate" the issue, as it came out of the box for me. Interestingly though, I do have another feature on the same page, which also is a macro, and also uses a multinodetreepicker the same way. That feature works; even after trying to delete all content and provoke an error. If anything, "the other" feature was added first, and the one I'm having problems with the second feature.

To clarify, the two features are separate macros, working completely independently from eachother. They are targeting different data types and different renderers. Both macros are rendered through the grid editor.

-- error

Received an error from the server An error occurred Error converting value "1128" to type 'Umbraco.Cms.Core.Udi'. Path 'ids[0]'.

Exception Details Newtonsoft.Json.JsonSerializationException, Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed: Error converting value "1128" to type 'Umbraco.Cms.Core.Udi'. Path 'ids[0]'. Stacktrace at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer) at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType) at Umbraco.Cms.Web.BackOffice.ModelBinders.FromJsonPathAttribute.JsonPathBinder.BindModelAsync(ModelBindingContext bindingContext) at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinder.BindModelAsync(ModelBindingContext bindingContext) at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value, Object container) at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>cDisplayClass0_0.<gBind|0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.gAwaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

umbrabot commented 2 years ago

Hiya @mattbrailsford,

Just wanted to let you know that we noticed that this issue got a bit stale and might not be relevant any more.

We will close this issue for now but we're happy to open it up again if you think it's still relevant (for example: it's a feature request that's not yet implemented, or it's a bug that's not yet been fixed).

To open it this issue up again, you can write @umbrabot still relevant in a new comment as the first line. It would be super helpful for us if on the next line you could let us know why you think it's still relevant.

For example:

@umbrabot still relevant This bug can still be reproduced in version x.y.z

This will reopen the issue in the next few hours.

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