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

Dapr Actors cannot serialize/deserialize ActorId/ActorReference #444

Closed
rynowak opened this issue Oct 19, 2020 · 1 comment · Fixed by #457
Closed

Dapr Actors cannot serialize/deserialize ActorId/ActorReference #444

rynowak opened this issue Oct 19, 2020 · 1 comment · Fixed by #457
Assignees
Labels
kind/bug Something isn't working P1

Comments

@rynowak
Copy link
Collaborator

rynowak commented Oct 19, 2020

Expected Behavior

ActorId and ActorReference work with the serializer and state store by default.

It's very common for actors to exchange their "addresses" and communicate with each other in asynchronous and disconnected ways. Using the primitive types that Dapr Actors provide should work for these usecases

Actual Behavior

The serializer throws an exception:

Exception has occurred: CLR/System.NotSupportedException
Exception thrown: 'System.NotSupportedException' in System.Private.CoreLib.dll: 'Deserialization of reference types without parameterless constructor is not supported. Type 'Dapr.Actors.ActorId''
   at System.Text.Json.ThrowHelper.ThrowNotSupportedException_DeserializeCreateObjectDelegateIsNull(Type invalidType)
   at System.Text.Json.JsonSerializer.HandleStartObject(JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadCore(JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& readStack)
   at System.Text.Json.JsonSerializer.ReadCore(Type returnType, JsonSerializerOptions options, Utf8JsonReader& reader)
   at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
   at Dapr.Actors.Runtime.DaprStateProvider.<TryLoadStateAsync>d__2`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Dapr.Actors.Runtime.ActorStateManager.<TryGetStateAsync>d__7`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at MatchMaker.MatchMakerActor.<RequestGameAsync>d__1.MoveNext() in /Users/ryan/github.com/rynowak/rock-paper-actors/src/MatchMaker/MatchMakerActor.cs:line 35

Steps to Reproduce the Problem

Create an actor that stores and reads an ActorReference from the state store.

Saving the reference will work, but reading it out will blow up on ActorId.

Release Note

RELEASE NOTE: FIX Bug in the Actors SDK for dotnet-sdk. Actor Reference and Id can now be stored.

@rynowak rynowak added the kind/bug Something isn't working label Oct 19, 2020
@vinayada1 vinayada1 added this to To do in 1.0.0 Milestone 1 via automation Oct 22, 2020
@vinayada1 vinayada1 added the P1 label Oct 23, 2020
@artursouza artursouza added this to To do in 1.0.0 Milestone Oct 27, 2020
@rynowak rynowak self-assigned this Oct 28, 2020
@rynowak
Copy link
Collaborator Author

rynowak commented Oct 28, 2020

@vinayada1 - assigning myself this one

@artursouza artursouza moved this from To do to Planned in 1.0.0 Milestone 1 Nov 3, 2020
@artursouza artursouza moved this from Planned to To do in 1.0.0 Milestone 1 Nov 3, 2020
rynowak added a commit that referenced this issue Nov 3, 2020
Fixes: #444

ActorId doesn't define a default constructor, and so it's not
deserializable via System.Text.Json.

This change implements a converter so that ActorId's API shape can work
with the serializer properly.

I added an integration test for ActorReference as well, but no library
changes we needed for that, ActorId was the blocker.
@rynowak rynowak mentioned this issue Nov 3, 2020
3 tasks
1.0.0 Milestone 1 automation moved this from To do to Review Nov 5, 2020
1.0.0 Milestone automation moved this from To do to Done Nov 5, 2020
rynowak added a commit that referenced this issue Nov 5, 2020
Fixes: #444

ActorId doesn't define a default constructor, and so it's not
deserializable via System.Text.Json.

This change implements a converter so that ActorId's API shape can work
with the serializer properly.

I added an integration test for ActorReference as well, but no library
changes we needed for that, ActorId was the blocker.
@artursouza artursouza moved this from Review to Done in 1.0.0 Milestone 1 Nov 6, 2020
@artursouza artursouza moved this from Done to Release in 1.0.0 Milestone 1 Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working P1
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants