From 2406f55af0691c287c5295941ade350e8d70ca19 Mon Sep 17 00:00:00 2001 From: Peter Farber Date: Fri, 30 Jan 2026 12:13:10 -0500 Subject: [PATCH 1/2] fix: check for unsigned report --- src/dev_snp.erl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/dev_snp.erl b/src/dev_snp.erl index aea38c63f..dc0dd26b6 100644 --- a/src/dev_snp.erl +++ b/src/dev_snp.erl @@ -216,9 +216,22 @@ extract_and_normalize_message(M2, NodeOpts) -> ) ), ?event({msg_with_json_report, {explicit, MsgWithJSONReport}}), - % Normalize the request message - ReportJSON = hb_ao:get(<<"report">>, MsgWithJSONReport, NodeOpts), - Report = hb_json:decode(ReportJSON), + % Normalize the request message. First try to get the report from the + % committed message. If not found (e.g., message not signed), fall back + % to the raw message. + ReportJSON = case hb_ao:get(<<"report">>, MsgWithJSONReport, NodeOpts) of + not_found -> + ?event({report_not_in_committed, falling_back_to_raw}), + hb_ao:get(<<"report">>, RawMsg, NodeOpts); + Found -> Found + end, + {ok, ValidReportJSON} ?= case ReportJSON of + not_found -> + ?event({report_not_found, {m2, M2}, {raw_msg, RawMsg}}), + {error, {report_not_found, <<"No 'report' key found in message">>}}; + _ -> {ok, ReportJSON} + end, + Report = hb_json:decode(ValidReportJSON), Msg = maps:merge( maps:without([<<"report">>], MsgWithJSONReport), From 762e703457d091b6c766e2aa7c01469d0e3a2e14 Mon Sep 17 00:00:00 2001 From: Peter Farber Date: Fri, 30 Jan 2026 12:25:46 -0500 Subject: [PATCH 2/2] fix: try to use m1 to find report --- src/dev_snp.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/dev_snp.erl b/src/dev_snp.erl index dc0dd26b6..48ce38a2b 100644 --- a/src/dev_snp.erl +++ b/src/dev_snp.erl @@ -61,8 +61,17 @@ verify(M1, M2, NodeOpts) -> ?event(snp_verify, verify_called), maybe + % In pipeline flows (e.g., /~relay@1.0/call/verify~snp@1.0), the report + % comes from M1 (result of previous stage). For direct calls, it may be + % in M2. Try M1 first, then fall back to M2. {ok, {Msg, Address, NodeMsgID, ReportJSON, MsgWithJSONReport}} - ?= extract_and_normalize_message(M2, NodeOpts), + ?= case extract_and_normalize_message(M1, NodeOpts) of + {ok, Result} -> {ok, Result}; + {error, {report_not_found, _}} -> + ?event(snp_verify, {report_not_in_m1_trying_m2}), + extract_and_normalize_message(M2, NodeOpts); + {error, ExtractReason} -> {error, ExtractReason} + end, % Perform all validation steps {ok, NonceResult} ?= verify_nonce(Address, NodeMsgID, Msg, NodeOpts), {ok, SigResult} ?=