From 48f3ade8bdf81f3e63d26ddb1f4529fcff38b77f Mon Sep 17 00:00:00 2001 From: Daniel Widgren Date: Sun, 24 May 2026 11:41:17 +0200 Subject: [PATCH] debug: logger=debug + try/catch verify_signature Two complementary changes to surface what is actually going wrong with webhook verification: 1. prod logger_level: info -> debug. Wider net so nothing is filtered. 2. Wrap gakudan_tickets_github:verify_signature/3 in try/catch with a ?LOG_ERROR that captures the crash class/reason/stack and the byte sizes of secret/body/sig. crypto:hash_equals/2 raises badarg when the two binaries differ in size; without this wrap the handler crashes and Nova renders a generic 500, which is what we just saw when probing with a short test signature. Real GitHub deliveries should not hit this, but the safety net + error log will tell us immediately if they do for some reason. --- config/prod_sys.config.src | 2 +- .../triagebot_webhook_controller.erl | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/config/prod_sys.config.src b/config/prod_sys.config.src index 699b53d..19f3e97 100644 --- a/config/prod_sys.config.src +++ b/config/prod_sys.config.src @@ -1,6 +1,6 @@ [ {kernel, [ - {logger_level, info}, + {logger_level, debug}, {logger, [ {handler, default, logger_std_h, #{ formatter => {nova_jsonlogger, #{ diff --git a/src/controllers/triagebot_webhook_controller.erl b/src/controllers/triagebot_webhook_controller.erl index ef32925..5a50187 100644 --- a/src/controllers/triagebot_webhook_controller.erl +++ b/src/controllers/triagebot_webhook_controller.erl @@ -28,7 +28,23 @@ github_event(Req) -> EventType = cowboy_req:header(~"x-github-event", Req1, ~""), Delivery = cowboy_req:header(~"x-github-delivery", Req1, ~""), Secret = triagebot_config:webhook_secret(), - case gakudan_tickets_github:verify_signature(Secret, Sig, Body) of + Valid = + try + gakudan_tickets_github:verify_signature(Secret, Sig, Body) + catch + Class:Reason:Stack -> + ?LOG_ERROR(#{ + event => verify_signature_crashed, + class => Class, + reason => Reason, + stack => Stack, + sig_byte_size => byte_size(Sig), + secret_byte_size => byte_size(Secret), + body_byte_size => byte_size(Body) + }), + false + end, + case Valid of false -> ?LOG_WARNING(#{ event => webhook_signature_invalid,