Kaynağa Gözat
fix(http action): correctly initialize resource state
Fixes https://emqx.atlassian.net/browse/EMQX-13608
Due to incorrect state initialization, a function clause that was supposed to match incoming messages fails, and later, after the message is transformed according to the wrong clauses, it leads to a cryptic function_clause error.
Adding more context:
```
2024-12-02T16:49:15.039945+00:00 [warning] msg: retrying_inflight_sync, where: {emqx_resource_buffer_worker,482,'emqx@127.0.0.1',<0.5531.0>}, query: {query,{fun emqx_rule_runtime:inc_action_metrics/2,[#{action_id => {bridge_v2,http,a},rule_id => <<"rule_zqm3">>}],#{reply_dropped => true}},{<<"action:http:a:connector:http:a">>,#{flags => #{dup => false,retain => false},id => <<"0006284C5426FF2AF4450000175B0169">>,node => 'emqx@127.0.0.1',timestamp => 1733158154731,peername => <<"172.100.239.1:33228">>,metadata => #{rule_id => <<"rule_zqm3">>},event => 'message.publish',username => undefined,payload => <<"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa">>,topic => <<"t/http">>,peerhost => <<"172.100.239.1">>,client_attrs => #{},clientid => <<"caribdis_bench_pub_3720746245_6">>,qos => 0,pub_props => #{'User-Property' => #{}},publish_received_at => 1733158154731}},true,-576460668807281086,undefined}, stk: {current_stacktrace,[{emqx_resource_buffer_worker,retry_inflight_sync,3,[{file,"src/emqx_resource_buffer_worker.erl"},{line,482}]},{gen_statem,loop_state_callback,11,[{file,"gen_statem.erl"},{line,1395}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,241}]}]}
2024-12-02T16:49:15.040025+00:00 [error] tag: ERROR, msg: resource_exception, info: #{error => {error,{invalid_request,#{request => #{flags => #{dup => false,retain => false},id => <<"0006284C5426FEE6F4450000175E0169">>,node => 'emqx@127.0.0.1',timestamp => 1733158154731,peername => <<"172.100.239.1:33254">>,metadata => #{rule_id => <<"rule_zqm3">>},event => 'message.publish',username => undefined,payload => <<"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa">>,topic => <<"t/http">>,peerhost => <<"172.100.239.1">>,client_attrs => #{},clientid => <<"caribdis_bench_pub_3711830288_8">>,qos => 0,pub_props => #{'User-Property' => #{}},publish_received_at => 1733158154731},method => <<"action:http:a:connector:http:a">>,base_path => "/"}}},id => <<"action:http:a:connector:http:a">>,name => call_query,request => {<<"action:http:a:connector:http:a">>,#{flags => #{dup => false,retain => false},id => <<"0006284C5426FEE6F4450000175E0169">>,node => 'emqx@127.0.0.1',timestamp => 1733158154731,peername => <<"172.100.239.1:33254">>,metadata => #{rule_id => <<"rule_zqm3">>},event => 'message.publish',username => undefined,payload => <<"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa">>,topic => <<"t/http">>,peerhost => <<"172.100.239.1">>,client_attrs => #{},clientid => <<"caribdis_bench_pub_3711830288_8">>,qos => 0,pub_props => #{'User-Property' => #{}},publish_received_at => 1733158154731}},stacktrace => [{emqx_bridge_http_connector,formalize_request,3,[{file,"src/emqx_bridge_http_connector.erl"},{line,865}]},{emqx_bridge_http_connector,on_query,3,[{file,"src/emqx_bridge_http_connector.erl"},{line,385}]},{emqx_resource_buffer_worker,apply_query_fun,9,[{file,"src/emqx_resource_buffer_worker.erl"},{line,1412}]},{emqx_resource_buffer_worker,call_query2,8,[{file,"src/emqx_resource_buffer_worker.erl"},{line,1250}]},{emqx_resource_buffer_worker,retry_inflight_sync,3,[{file,"src/emqx_resource_buffer_worker.erl"},{line,483}]},{gen_statem,loop_state_callback,11,[{file,"gen_statem.erl"},{line,1395}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,241}]}]}
```
Cause: lack of `installed_actions` key in connector state returned by on_start, and the
connector restarting amidst ongoing traffic.