Closed PeatLaur closed 2 years ago
I have seen some similar exceptions in Umbraco v9.0.1 on Umbraco Cloud, which throws an exception when opening MNTP. I don't recall it original was an issue when I starting on the project on v9.0.0
See more in this issue: https://github.com/umbraco/Umbraco-CMS/issues/11448
Hi Bjarnef, I have more information on the above error: From Chrome dev tools:
Possibly unhandled rejection: {"errorMsg":"Failed to retrieve url map for udis 1113,1137,1269,1565,1107","data":{"ExceptionMessage":"Error converting value \"1113\" to type 'Umbraco.Cms.Core.Udi'. Path 'udis[0]'.","ExceptionType":"Newtonsoft.Json.JsonSerializationException, Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed","StackTrace":" at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)\r\n at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)\r\n at Umbraco.Cms.Web.BackOffice.ModelBinders.FromJsonPathAttribute.JsonPathBinder.BindModelAsync(ModelBindingContext bindingContext)\r\n at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinder.BindModelAsync(ModelBindingContext bindingContext)\r\n at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value, Object container)\r\n at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)"},"status":500}
https://localhost:44312/umbraco/backoffice/umbracoapi/entity/GetUrlsByUdis?culture=
So basically, on the surface it looks like the function is being fed the id as an integer, but what it needs now is the Udi
I will see what else I can find. I am thinking of looking at the Umbraco source code to get some more details and possible solution. A lot of our in page macros use the Multiple Content Picker to help in creating a series of links in many macros, so if this is not resolved we cannot upgrade our website to 9.1. So far I have been very impressed with this new version of Umbraco, and hope this issue is quickly and easily resolved.
Hi, So far I have found the function in the Umbraco source code that generates the error. This is only recently been added, as I could not find it in the source code I had downloaded a few weeks back.
I done a search on Umbraco CMS with the following: https://github.com/umbraco/Umbraco-CMS/search?q=GetUrlsByUdis
this is in Umbraco.Web.UI.Client src > common > resources > entity.resource.js
Line 130
getUrlsByUdis: function(udis, culture) { var query = "culture=" + (culture || "");
return umbRequestHelper.resourcePromise( $http.post( umbRequestHelper.getApiUrl( "entityApiBaseUrl", "GetUrlsByUdis", query), { udis: udis }), 'Failed to retrieve url map for udis ' + udis); }
Most of the core property editors use entityResource
to lookup entities and this resource use EntityController
.
In v9 it seems the GetUrlsByUdis
only support Udi[]
https://github.com/umbraco/Umbraco-CMS/blob/v9/contrib/src/Umbraco.Web.BackOffice/Controllers/EntityController.cs#L334
but was also the case in v8: https://github.com/umbraco/Umbraco-CMS/blob/v8/contrib/src/Umbraco.Web/Editors/EntityController.cs#L251
The Multiple Content Pickers for Macro Parameters, still, I think store integer Ids. If you created a new parameter editor based on the Multinode tree picker with idType set to udi...
DefaultConfiguration.Add("idType", "udi");
would that workaround the issue?
(also possibly related: https://github.com/umbraco/Umbraco-CMS/issues/10951 and https://github.com/umbraco/Umbraco-CMS/pull/8388
Hi Marcemarc, Thank you for your reply, and thank you all for your replies above. I have been reading through the related issues you put in links to, and yes, they do seem to describe the issue, with multiple content picker using ids and not Udi. From the looks of it this issue may not be remedied soon. In the issue #8388 the monitor team reported: Causes issues around changing data with existing editors and deploy - better to change in a new major version - remove legacy int ids and changes to udi.
I will look in to your suggestion about creating a new custom multinode tree picker, and read the following documentation: https://our.umbraco.com/documentation/extending/macro-parameter-editors/
Kind regards
Hi Marcemarc, I have finally resolved what to do to create a new parameter editor, based on the Multinode tree picker as you suggested. I used the following code and added the DefaultConfiguration as you suggested:
I created a c# class file: CmtMultipleUrlPickerParameterEditor.cs
using Umbraco.Cms.Core.PropertyEditors;
namespace YourNameSpace.SomeFolder.ParameterEditor
{
[DataEditor(
"Cmt.MultipleUrlPickerParameterEditor",
EditorType.MacroParameter,
"Cmt Multiple Url Content Picker",
"contentpicker")]
public CmtMultipleUrlPickerParameterEditor (
IDataValueEditorFactory dataValueEditorFactory)
: base(dataValueEditorFactory)
{
// configure
DefaultConfiguration.Add("multiPicker", "1");
DefaultConfiguration.Add("minNumber", 0);
DefaultConfiguration.Add("maxNumber", 0);
DefaultConfiguration.Add("idType", "udi");
}
}
The following code in the macro was used:
var getContentList = macroParams.SingleOrDefault(x => x.Key == "interlinkingPicker").Value;
var contentIDs = getContentList.ToString().Split(',').SelectMany(s => s.Split(',').Select(x => x));
var contentList = Umbraco.Content(contentIDs.ToArray<string>());
@foreach (var item in contentList) {
@item.Url()
}
Kind regards.
@PeatLaur hurrah and does this work around the issue? eg no more errors?
@marcemarc Yes thank you, No more errors. I have to re-apply the macros that I have recoded (re-do the links), but for a few hours work and some aspects of the new Umbraco 9 net core build well learned over the last couple of days, I reckon it is worth it in the long run.
Ok, I have had a look to see what has changed between 9.0.0 and 9.1.0RC and have confirmed the issue does not exist in 9.0.0 but does exist in 9.1.0RC.
And my guess is I think it is this change: https://github.com/umbraco/Umbraco-CMS/commit/4eb75799e7458ddebec05958b53e80b2030ad8d7 by @p-m-j to make the Content Picker use GetUrlsByUdis...
as Macro Parameter Content Pickers are set to store integer Ids and not Udis (they don't have their idType set.... @nul800sebastiaan says it should be ok to make this change in V10! :-P)
... anyway think it results in the integer ids being sent to getUrlsByUdis, which then triggers the error:
Error converting value "1059" to type 'Umbraco.Cms.Core.Udi'. Path 'udis[0]'.
because the integer is not a udi!
@PeatLaur has shown by creating a new macro parameter editor with the idType set to udi, that it all works...
so one fix would be to update the macro parameter content picker to use udis! (but that's a change we don't want to make until V10!)
or
only call getUrlsByUdis if the config idType is explicitly set to be udi???
How to create the issue?
<h1>@Model.MacroParameters["multipleContentPicker"]</h1>
righto, sounds like we need support for integers in ~9.1.1~ 9.1.2 & 8.18 :)
I have a similar issue, but with MNTP, which stores an Udi
, but it seems something changed from v9.0.0 to v9.0.1 as I currently have issues selecting nodes in MNTP and show what previous was selected when the project was on v9.0.0
https://github.com/umbraco/Umbraco-CMS/issues/11647
@p-m-j I am encouraged by your comment: righto, sounds like we need support for integers in 9.1.1 & 8.18 and @marcemarc by your idea: only call getUrlsByUdis if the config idType is explicitly set to be udi??? Instead of going through all the pages in our website, after upgrading the database to Umbraco 9, to re-do all the links in the affected Macros, that I just hold off until 9.1.1, and I also hold off upgrading the live site until 8.18 is released. I will see. But I am glad that this issue is being looked in to and thanks to the Umbraco team.
Hi @p-m-j and @marcemarc I have upgraded our test website to Umbraco 9.1.1 and used an upgraded database from our Umbraco 8.16.0 build which uses the Multi Node Tree pickers in the Macros, that were fine, when I upgraded to Umbraco 9.01,
No picker works still on 9.1.1 I have also tried the code below, which I did get to work on Umbraco 9.1, but this errors now.
using Umbraco.Cms.Core.PropertyEditors;
namespace YourNameSpace.SomeFolder.ParameterEditor
{
[DataEditor(
"Cmt.MultipleUrlPickerParameterEditor",
EditorType.MacroParameter,
"Cmt Multiple Url Content Picker",
"contentpicker")]
public CmtMultipleUrlPickerParameterEditor (
IDataValueEditorFactory dataValueEditorFactory)
: base(dataValueEditorFactory)
{
// configure
DefaultConfiguration.Add("multiPicker", "1");
DefaultConfiguration.Add("minNumber", 0);
DefaultConfiguration.Add("maxNumber", 0);
DefaultConfiguration.Add("idType", "udi");
}
}
Is this not going to be fixed in Umbraco 9? If not I will cut my losses and not use Macros for these linking sections in our website going forward and drop all use of tree node pickers in Macros. Thank you in advance for your replies. Kind regards.
9.1.1 went out before the fixes in https://github.com/umbraco/Umbraco-CMS/pull/11685 were completed. I don't think 9.1.2 will be far behind.
@PeatLaur - pushed preview to umbraco nightly if you want to give it a try.
Add nuget source e.g with NuGet.config in project root
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="umbraconightly" value="https://www.myget.org/F/umbraconightly/api/v3/index.json" />
</packageSources>
</configuration>
Update csproj PackageRef
<ItemGroup>
<PackageReference Include="Umbraco.Cms" Version="9.1.1-preview20211123.77953" />
</ItemGroup>
Hi @p-m-j Thank you for the feedback. I tried the same process (results below) after adding the nightly build config and package reference as instructed.
I had the following error using the normal Multi Content Picker (MultiNodeTreePicker): POST https://localhost:44312/umbraco/backoffice/umbracoapi/entity/GetUrlsByUdis?culture= 500
error: Error converting value \"1113\" to type 'Umbraco.Cms.Core.Udi'. Path 'udis[0]
Possibly unhandled rejection: {"errorMsg":"Failed to retrieve url map for udis 1113,1137,1269,1565","data":{"ExceptionMessage":"Error converting value \"1113\" to type 'Umbraco.Cms.Core.Udi'. Path 'udis[0]'.","ExceptionType":"Newtonsoft.Json.JsonSerializationException, Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed","StackTrace":" at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)\r\n at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)\r\n at Umbraco.Cms.Web.BackOffice.ModelBinders.FromJsonPathAttribute.JsonPathBinder.BindModelAsync(ModelBindingContext bindingContext)\r\n at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinder.BindModelAsync(ModelBindingContext bindingContext)\r\n at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value, Object container)\r\n at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>cDisplayClass0_0.<
Then I tried switching to the custom macro parameter editor as I tried before (and worked) with DefaultConfiguration.Add("idType", "udi"); This errored as well, but the error is slightly different to that above:
It now says: Could not convert string to integer
Possibly unhandled rejection: {"errorMsg":"Failed to retrieve entity data for ids 1113,1137,1269,1565,umb://document/b17c523538c9460ba471395ed44f8ac8","data":{"ExceptionMessage":"Could not convert string to integer: umb://document/b17c523538c9460ba471395ed44f8ac8. Path 'ids[4]'.","ExceptionType":"Newtonsoft.Json.JsonReaderException, Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed","StackTrace":" at Newtonsoft.Json.JsonReader.ReadInt32String(String s)\r\n at Newtonsoft.Json.JsonReader.ReadAsInt32()\r\n at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)\r\n at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)\r\n at Umbraco.Cms.Web.BackOffice.ModelBinders.FromJsonPathAttribute.JsonPathBinder.BindModelAsync(ModelBindingContext bindingContext)\r\n at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinder.BindModelAsync(ModelBindingContext bindingContext)\r\n at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value, Object container)\r\n at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>cDisplayClass0_0.<
I tested that package locally before I posted to ensure it works.
The MNTP no longer uses the endpoint GetUrlsByUdis but instead GetUrlsByIds which means you are likely having issues with cached JavaScript.
Probably worth running browser in developer mode with no-cache on but I imagine it could be smidge issues, if you try invalidate by adding a version in https://our.umbraco.com/Documentation/Reference/V9-Config/RuntimeMinificationSettings/ that should resolve it
Hi @p-m-j Yes, I re-ran my tests after checking the cache and JS as you instructed and I can confirm that all was ok, with a straight duplicate of our Umbraco 8.16 database, opened in our Umbraco 9.1.1-preview20211123.77953 nightly build and after the system upgraded the database, I was able to go straight in and view the existing links and edit them. Apologies for the doubt I put forward earlier and once again thank you for this resolution. Kind regards
No worries, just glad to hear it's resolved!
Which exact Umbraco version are you using? For example: 9.0.1 - don't just write v9
9.1.0-rc
Bug summary
Our macros use Multiple Content Picker (Umbraco.MultiNodeTreePicker) to select a number of paths to include in the macro to other pages on the website. This works fine in Umbraco 8 and Umbraco 9.0 and 9.0.1 After upgrading my development version to 9.1, although the links are OK on the face of it, when viewed on the website, when I try to access them in the CMS to edit them or change them etc. when the macro is loaded we get a Newtonsoft.Json.JsonSerializationException and the links are not displayed in the cms. The links cannot be edited. I cannot re-add the links - which would be a tedious task, as these are on every page - if we had to do that for Umbraco 9.1
I also tried creating a completely new macro with just the Multiple Content Picker as a parameter, but after adding it to the page, on every attempt to add a link, the same error happened and I was not able to add any links.
Image 1: Showing the property used in the Macro - Multi Node Tree Picker![cms-settings-showing-multi-node-tree-picker](https://user-images.githubusercontent.com/48582574/141673361-0a9b03c0-b92c-4fe7-951b-ffb8ade9051e.jpg)
Image 2: Showing displayed list of links in Umbraco 9.01![cms-9 0 1-links-displaying-ok-no-error](https://user-images.githubusercontent.com/48582574/141673415-f6b61ed1-c80f-4748-80bb-a72510d4fd75.jpg)
Image 3: Showing the error displayed when going in to edit a macro in 9.1 rc![cms-error](https://user-images.githubusercontent.com/48582574/141673438-5552e9a0-8237-449b-b80b-c799d62ab7c0.jpg)
Image 4: Showing that no links are displayed after the error above![cms-9 1-rc-links-not-displaying](https://user-images.githubusercontent.com/48582574/141673457-731c9a39-cb62-4067-b8ac-d2454f188c6b.jpg)
I hope that this is looked and and the error corrected before the release of 9.1 later this coming week.
Specifics
Example of the error when accessing a Macro in a content page in the CMS:
Error converting value "1113" to type 'Umbraco.Cms.Core.Udi'. Path 'udis[0]'.
Newtonsoft.Json.JsonSerializationException, Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed: Error converting value "1113" to type 'Umbraco.Cms.Core.Udi'. Path 'udis[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.g Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
Steps to reproduce
1: Create a Macro 2: Add Parameter - Umbraco.MultiNodeTreePicker (Multiple Content Picker) 3: Allow the macro to be included in a rich text area or grid 4: Include the macro in a rich text area and try to add a link using the above parameter. You get the error shown below and no link added to the list![cms-9 1-rc-test-using-multiple-content-picker](https://user-images.githubusercontent.com/48582574/141674019-1d95c380-7d7f-4691-bfe4-8cb1fe192034.jpg)
Expected result / actual result
The ability to add or edit links in the multiple content picker list:![cms-9 0 1-links-displaying-ok-no-error](https://user-images.githubusercontent.com/48582574/141674044-12840d73-d36d-4e4a-88c9-28e30d638b86.jpg)
_This item has been added to our backlog AB#15130_