Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static command empty dictionary<int,int> as input param error #1834

Open
tengulak opened this issue Jul 6, 2024 · 1 comment
Open

static command empty dictionary<int,int> as input param error #1834

tengulak opened this issue Jul 6, 2024 · 1 comment
Milestone

Comments

@tengulak
Copy link

tengulak commented Jul 6, 2024

Newtonsoft.Json.JsonSerializationExceptionCannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Collections.Generic.Dictionary`2[System.Int32,System.Int32]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path 'args[0].SelectedItems', line 1, position 17440.

{ ... }
JsonArrayContract Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureArrayContract(JsonReader reader, Type objectType, JsonContract contract)
object Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, object existingValue, string id)
object Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue)
List Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolvePropertyAndCreatorValues(JsonObjectContract contract, JsonProperty containerProperty, JsonReader reader, Type objectType)
object Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObjectUsingCreatorWithParameters(JsonReader reader, JsonObjectContract contract, JsonProperty containerProperty, ObjectConstructor creator, string id)
object Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue)
object Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue)
object Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, bool checkAdditionalContent)
object Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
object Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
Task DotVVM.Framework.Hosting.StaticCommandExecutor.Execute(StaticCommandInvocationPlan plan, IEnumerable arguments, IEnumerable argumentValidationPaths, IDotvvmRequestContext context)+DeserializeArgument(Type type, int index)
Source File: _\src\Framework\Framework\Hosting\StaticCommandExecutor.cs:66

async Task DotVVM.Framework.Hosting.StaticCommandExecutor.Execute(StaticCommandInvocationPlan plan, Queue arguments, Queue argumentValidationPaths, IDotvvmRequestContext context)
async Task DotVVM.Framework.Utils.TaskUtils.ToObjectTask(object taskOrSomething)
Source File: _\src\Framework\Framework\Utils\TaskUtils.cs:20

async Task DotVVM.Framework.Hosting.DotvvmPresenter.ExecuteCommand(ActionInfo action, IDotvvmRequestContext context, IEnumerable methodFilters)
Source File: _\src\Framework\Framework\Hosting\DotvvmPresenter.cs:411

System.ExceptionUnhandled exception occurred in the command!

@tengulak tengulak changed the title static commnd dictionary as input param error static command dictionary as input param error Jul 6, 2024
@tengulak tengulak changed the title static command dictionary as input param error static command empty dictionary as input param error Jul 6, 2024
@tengulak tengulak changed the title static command empty dictionary as input param error static command empty dictionary<int,int> as input param error Jul 6, 2024
@exyi
Copy link
Member

exyi commented Jul 7, 2024

Thanks for reporting the issue. I believe this one is caused by a partially fixed bug that we don't use the DotVVM serialized for input arguments and instead call the Newtonsoft.Json converter. Since the fix has the potential to break some existing code, it has to be enabled as an "experimental feature":

config.ExperimentalFeatures.UseDotvvmSerializationForStaticCommandArguments()

@exyi exyi added this to the Version 5.0 milestone Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants