From 6acb29621cf5a9903d5b6603f9951503f9a5f8f5 Mon Sep 17 00:00:00 2001 From: Niclas Axelsson Date: Tue, 23 Sep 2025 21:54:47 +0200 Subject: [PATCH 1/2] Returns the proper http-code if `{stop, {reply, ...}, req, state}` is returned from plugin --- src/nova_plugin_handler.erl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nova_plugin_handler.erl b/src/nova_plugin_handler.erl index ae532f8f..9a775e04 100644 --- a/src/nova_plugin_handler.erl +++ b/src/nova_plugin_handler.erl @@ -52,6 +52,8 @@ run_plugins([{Callback, Options}|Tl], CallbackType, Req, Env) when is_function(C {stop, Req0}; {stop, Reply, Req0, _State0} -> Req1 = handle_reply(Reply, Req0), + %% Since we are stopping we need to send the statuscode to the requester. This is a special case for stop. + cowboy_req:reply(Req1#resp_status_code, Req1), {stop, Req1} end catch From 60d0942fd6876d7adb3cf77eb6f327c50e94340d Mon Sep 17 00:00:00 2001 From: Niclas Axelsson Date: Tue, 23 Sep 2025 21:56:57 +0200 Subject: [PATCH 2/2] Fix syntax error --- src/nova_plugin_handler.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nova_plugin_handler.erl b/src/nova_plugin_handler.erl index 9a775e04..0becaa36 100644 --- a/src/nova_plugin_handler.erl +++ b/src/nova_plugin_handler.erl @@ -53,7 +53,8 @@ run_plugins([{Callback, Options}|Tl], CallbackType, Req, Env) when is_function(C {stop, Reply, Req0, _State0} -> Req1 = handle_reply(Reply, Req0), %% Since we are stopping we need to send the statuscode to the requester. This is a special case for stop. - cowboy_req:reply(Req1#resp_status_code, Req1), + StatusCode = maps:get(resp_status_code, Req1, 200), + cowboy_req:reply(StatusCode, Req1), {stop, Req1} end catch