Skip to content

Elixir.FunctionClauseError on Coherence.update_user_logins function #384

@dskim

Description

@dskim

Hi,

I'm just wondering if this is something that needs to be fixed or I'm using it wrong.

I'm not exactly sure how this is happening as I don't see the sender of this request, but I'm getting this exception.

Elixir.FunctionClauseError: no function clause matching in anonymous fn/1 in Coherence.CredentialStore.Server.handle_cast/2
  File "lib/coherence/plugs/authorization/credential_store/server.ex", line 88, in anonymous fn/1 in Coherence.CredentialStore.Server.handle_cast/2
  File "lib/kernel.ex", line 2136, in anonymous fn/2 in Kernel.update_in/3
  File "lib/map.ex", line 791, in Map.get_and_update/3
  File "lib/kernel.ex", line 2136, in Kernel.update_in/3
  File "lib/coherence/plugs/authorization/credential_store/server.ex", line 88, in Coherence.CredentialStore.Server.handle_cast/2
  File "gen_server.erl", line 637, in :gen_server.try_dispatch/4
  File "gen_server.erl", line 711, in :gen_server.handle_msg/6
  File "proc_lib.erl", line 249, in :proc_lib.init_p_do_apply/3
  Module "Elixir.Coherence.CredentialStore.Server", in Coherence.CredentialStore.Server.init/1

We're calling Coherence.update_user_logins(user) when admin updates user's record in order to make sure the logged in users credentials gets updated as well.
I think exception is happening due to the fact that the user is not logged in at the time of this update as this code below doesn't seem to handle signed out users.

https://github.com/smpallen99/coherence/blob/master/lib/coherence/plugs/authorization/credential_store/server.ex#L94

I'm wondering if we need to add extra match something like fn nil -> nil to make sure we gracefully handle cases where the user data doesn't present on the GenServer.

Please let me know if this seems like a way to go, I'll submit a PR for that.

Thanks,
David

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions