travelping / hello

Erlang RPC server framework
MIT License
32 stars 20 forks source link

crash with encode_single #67

Closed umatomba closed 9 years ago

umatomba commented 9 years ago

trying to send hello request i got this: 10:35:30.803 [error] Error in process <0.3343.0> on node 'tposs_ccs@127.0.0.1' with exit value: {function_clause,[{hello_proto_jsonrpc,encode_single,[bad_signature],[{file,"src/protocols/hello_proto_jsonrpc.erl"},{line,85}]},{hello_proto_jsonrpc,encode,2,[{file,"src/protocols/hello_proto_jsonrpc.erl"},{line.

trace hello_proto_jsonrpc:

10:24:25.061 [debug] DELETE FROM `carrier_group` WHERE `id` = ? [1] ERROR query=16.7ms queue=0.1ms

#PID<0.3076.0> call :hello_proto_jsonrpc.signature([decoder: :hello_json])
#PID<0.3076.0> returned :hello_proto_jsonrpc.signature/1 -> <<170, 255>>

#PID<0.3076.0> call :hello_proto_jsonrpc.decode("{\"id\":41,\"params\":{\"id\":1,\"resource\":\"carrier_group\"},\"method\":\"delete\",\"jsonrpc\":\"2.0\"}", [decoder: :hello_json], :request)

#PID<0.3076.0> call :hello_proto_jsonrpc.decode_single(%{"id" => 41, "jsonrpc" => "2.0", "method" => "delete", "params" => %{"id" => 1, "resource" => "carrier_group"}}, :request)
#PID<0.3076.0> call :hello_proto_jsonrpc.req_version(%{"id" => 41, "jsonrpc" => "2.0", "method" => "delete", "params" => %{"id" => 1, "resource" => "carrier_group"}})
#PID<0.3076.0> returned :hello_proto_jsonrpc.req_version/1 -> 2
#PID<0.3076.0> call :hello_proto_jsonrpc.request_id(2, %{"id" => 41, "jsonrpc" => "2.0", "method" => "delete", "params" => %{"id" => 1, "resource" => "carrier_group"}})
#PID<0.3076.0> returned :hello_proto_jsonrpc.request_id/2 -> 41
#PID<0.3076.0> call :hello_proto_jsonrpc.decode_single(:request, %{"id" => 41, "jsonrpc" => "2.0", "method" => "delete", "params" => %{"id" => 1, "resource" => "carrier_group"}}, {:jsonrpc_info, 41, 2})
#PID<0.3076.0> call :hello_proto_jsonrpc.type(41)
#PID<0.3076.0> returned :hello_proto_jsonrpc.type/1 -> :sync
#PID<0.3076.0> returned :hello_proto_jsonrpc.decode_single/3 -> {:ok, {:request, :sync, :undefined, :undefined, {:jsonrpc_info, 41, 2}, "delete", %{"id" => 1, "resource" => "carrier_group"}}}
#PID<0.3076.0> returned :hello_proto_jsonrpc.decode_single/2 -> {:ok, {:request, :sync, :undefined, :undefined, {:jsonrpc_info, 41, 2}, "delete", %{"id" => 1, "resource" => "carrier_group"}}}
#PID<0.3076.0> returned :hello_proto_jsonrpc.decode/3 -> {:ok, {:request, :sync, :undefined, :undefined, {:jsonrpc_info, 41, 2}, "delete", %{"id" => 1, "resource" => "carrier_group"}}}

#PID<0.3076.0> call :hello_proto_jsonrpc.encode({:response, :undefined, :undefined, {:jsonrpc_info, 41, 2}, {:error, :server_error, 'handler error', :undefined}}, [decoder: :hello_json])
#PID<0.3076.0> call :hello_proto_jsonrpc.encode_single({:response, :undefined, :undefined, {:jsonrpc_info, 41, 2}, {:error, :server_error, 'handler error', :undefined}})
#PID<0.3076.0> call :hello_proto_jsonrpc.encode_single({:error, :server_error, 'handler error', :undefined})
#PID<0.3076.0> call :hello_proto_jsonrpc.build_error({:error, :server_error, 'handler error', :undefined})

#PID<0.3076.0> returned :hello_proto_jsonrpc.build_error/1 -> {:error, -32002, "Server Error: handler error", :undefined}
#PID<0.3076.0> call :hello_proto_jsonrpc.maybe_null("Server Error: handler error")
#PID<0.3076.0> returned :hello_proto_jsonrpc.maybe_null/1 -> "Server Error: handler error"
#PID<0.3076.0> call :hello_proto_jsonrpc.maybe_null(-32002)
#PID<0.3076.0> returned :hello_proto_jsonrpc.maybe_null/1 -> -32002
#PID<0.3076.0> returned :hello_proto_jsonrpc.encode_single/1 -> [{"message", "Server Error: handler error"}, {"code", -32002}]
#PID<0.3076.0> returned :hello_proto_jsonrpc.encode_single/1 -> [{"error", [{"message", "Server Error: handler error"}, {"code", -32002}]}, {"id", 41}, {"jsonrpc", "2.0"}]
#PID<0.3076.0> returned :hello_proto_jsonrpc.encode/2 -> {:ok, "{\"error\":{\"message\":\"Server Error: handler error\",\"code\":-32002},\"id\":41,\"jsonrpc\":\"2.0\"}"}
iex(tposs_ccs@127.0.0.1)6> 
nil
#PID<0.3083.0> call :hello_proto_jsonrpc.signature([decoder: :hello_json])
#PID<0.3083.0> returned :hello_proto_jsonrpc.signature/1 -> <<170, 255>>

#PID<0.3083.0> call :hello_proto_jsonrpc.encode(:bad_signature, [decoder: :hello_json])
#PID<0.3083.0> call :hello_proto_jsonrpc.encode_single(:bad_signature)
#PID<0.3083.0> exception :hello_proto_jsonrpc.encode_single/1 -> :error::function_clause
#PID<0.3083.0> exception :hello_proto_jsonrpc.encode/2 -> :error::function_clause
2015-08-28 10:24:25.062 [error] <0.3077.0>@hello_handler:handle_cast:132 service: 'CarrierGroup.Api' handler thrown an error for method: <<"delete">>, args: #{<<"id">> => 1,<<"resource">> => <<"carrier_group">>} error: {error,function_clause,[{'Elixir.Exd.Api.Crud',export_data,[#{'__exception__' => true,'__struct__' => 'Elixir.Mariaex.Error',mariadb => #{code => 1451,message => <<"Cannot delete or update a parent row: a foreign key constraint fails (`tposs_ccs`.`carrier`, CONSTRAINT `carrier_ibfk_1` FOREIGN KEY (`carrier_group_id`) REFERENCES `carrier_group` (`id`))">>},message => nil},[{as,write}]],[{file,"lib/exd/api/crud.ex"},{line,239}]},{'Elixir.Exd.Plugin.Hello',handle_request,4,[{file,"lib/exd/plugin/hello.ex"},{line,20}]},{hello_handler,do_request,2,[{file,"src/hello_handler.erl"},{line,197}]},{hello_handler,handle_cast,2,[{file,"src/hello_handler.erl"},{line,128}]},{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,599}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,237}]}]}
2015-08-28 10:24:37.276 [error] emulator Error in process <0.3083.0> on node 'tposs_ccs@127.0.0.1' with exit value: {function_clause,[{hello_proto_jsonrpc,encode_single,[bad_signature],[{file,"src/protocols/hello_proto_jsonrpc.erl"},{line,85}]},{hello_proto_jsonrpc,encode,2,[{file,"src/protocols/hello_proto_jsonrpc.erl"},{line...

successfull request trace on the same time:

#PID<0.3133.0> call :hello_proto_jsonrpc.signature([decoder: :hello_json])
#PID<0.3133.0> returned :hello_proto_jsonrpc.signature/1 -> <<170, 255>>

#PID<0.3133.0> call :hello_proto_jsonrpc.decode("{\"id\":42,\"params\":{\"id\":1,\"resource\":\"tariff\"},\"method\":\"delete\",\"jsonrpc\":\"2.0\"}", [decoder: :hello_json], :request)

#PID<0.3133.0> call :hello_proto_jsonrpc.decode_single(%{"id" => 42, "jsonrpc" => "2.0", "method" => "delete", "params" => %{"id" => 1, "resource" => "tariff"}}, :request)
#PID<0.3133.0> call :hello_proto_jsonrpc.req_version(%{"id" => 42, "jsonrpc" => "2.0", "method" => "delete", "params" => %{"id" => 1, "resource" => "tariff"}})
#PID<0.3133.0> returned :hello_proto_jsonrpc.req_version/1 -> 2
#PID<0.3133.0> call :hello_proto_jsonrpc.request_id(2, %{"id" => 42, "jsonrpc" => "2.0", "method" => "delete", "params" => %{"id" => 1, "resource" => "tariff"}})
#PID<0.3133.0> returned :hello_proto_jsonrpc.request_id/2 -> 42
#PID<0.3133.0> call :hello_proto_jsonrpc.decode_single(:request, %{"id" => 42, "jsonrpc" => "2.0", "method" => "delete", "params" => %{"id" => 1, "resource" => "tariff"}}, {:jsonrpc_info, 42, 2})
#PID<0.3133.0> call :hello_proto_jsonrpc.type(42)
#PID<0.3133.0> returned :hello_proto_jsonrpc.type/1 -> :sync
#PID<0.3133.0> returned :hello_proto_jsonrpc.decode_single/3 -> {:ok, {:request, :sync, :undefined, :undefined, {:jsonrpc_info, 42, 2}, "delete", %{"id" => 1, "resource" => "tariff"}}}
#PID<0.3133.0> returned :hello_proto_jsonrpc.decode_single/2 -> {:ok, {:request, :sync, :undefined, :undefined, {:jsonrpc_info, 42, 2}, "delete", %{"id" => 1, "resource" => "tariff"}}}

#PID<0.3133.0> returned :hello_proto_jsonrpc.decode/3 -> {:ok, {:request, :sync, :undefined, :undefined, {:jsonrpc_info, 42, 2}, "delete", %{"id" => 1, "resource" => "tariff"}}} 
iex(tposs_ccs@127.0.0.1)28> 
10:25:57.650 [debug] SELECT t0.`id`, t0.`name`, t0.`type`, t0.`quantum`, t0.`inserted_at`, t0.`updated_at` FROM `tariff` AS t0 WHERE (t0.`id` = ?) [1] OK query=2.0ms queue=0.1ms 

#PID<0.3133.0> call :hello_proto_jsonrpc.encode({:response, :undefined, :undefined, {:jsonrpc_info, 42, 2}, nil}, [decoder: :hello_json])
#PID<0.3133.0> call :hello_proto_jsonrpc.encode_single({:response, :undefined, :undefined, {:jsonrpc_info, 42, 2}, nil})
#PID<0.3133.0> returned :hello_proto_jsonrpc.encode_single/1 -> [{"result", nil}, {"id", 42}, {"jsonrpc", "2.0"}]
#PID<0.3133.0> returned :hello_proto_jsonrpc.encode/2 -> {:ok, "{\"result\":\"nil\",\"id\":42,\"jsonrpc\":\"2.0\"}"}
surik commented 9 years ago

Three are two problems: 1) bad_signature. Old hello client talks with new hello server, you should update. 2) Server Error: handler error. Something wrong with handler (error in exd). You should update too :)