-
-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Trying to use the Redis session crashes when a server tries to restore a session because the log_level is nil, but required.
iex(20)> {:ok, keys} = Redix.command(conn, ["KEYS", "mcp:sessions:*"])
{:ok, ["mcp:sessions:session_GICSuMQUiNGQQ0qN1rE="]}
iex(21)> {:ok, json} = Redix.command(conn, ["GET", List.first(keys)])
{:ok,
"{\"id\":\"session_GICSuMQUiNGQQ0qN1rE=\",\"client_info\":{\"name\":\"Postman Client\",\"version\":\"1.0.0\"},\"initialized\":true,\"log_level\":null,\"protocol_version\":\"2025-03-26\",\"pending_requests\":{},\"client_capabilities\":{\"elicitation\":{},\"sampling\":{}}}"}
iex(22)> Jason.decode!(json)
%{
"client_capabilities" => %{"elicitation" => %{}, "sampling" => %{}},
"client_info" => %{"name" => "Postman Client", "version" => "1.0.0"},
"id" => "session_GICSuMQUiNGQQ0qN1rE=",
"initialized" => true,
"log_level" => nil,
"pending_requests" => %{},
"protocol_version" => "2025-03-26"
}
Leading to a GenServer crash:
{:bad_return_value, {:error, {{:badmatch, {:error, [%Peri.Error{path: [:log_level], key: :log_level, content: %{expected: :string}, message: "is required, expected type of :string", errors: nil}]}}, [{Anubis.Server.Session, :maybe_restore_session, 3, [file: ~c"lib/anubis/server/session.ex", line: 193]}, {Anubis.Server.Session, :start_link, 1, [file: ~c"lib/anubis/server/session.ex", line: 57]}, {DynamicSupervisor, :start_child, 3, [file: ~c"lib/dynamic_supervisor.ex", line: 765]}, {DynamicSupervisor, :handle_start_child, 2, [file: ~c"lib/dynamic_supervisor.ex", line: 751]}, {:gen_server, :try_handle_call, 4, [file: ~c"gen_server.erl", line: 2381]}, {:gen_server, :handle_msg, 6, [file: ~c"gen_server.erl", line: 2410]}, {:proc_lib, :init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 329]}]}}}
--
Quick fix might just be to add a default here:
https://github.com/zoedsoupe/anubis-mcp/blob/main/lib/anubis/server/session.ex#L25
The server should also likely be more resilient to problems in the session and default to just not restoring bad sessions. As is, Anubis appears to be unusable when running one more than 1 server (without sticky session cookies.)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels