diff --git a/src/hb_ao.erl b/src/hb_ao.erl index 69c7a000c..af4355c89 100644 --- a/src/hb_ao.erl +++ b/src/hb_ao.erl @@ -826,6 +826,8 @@ ensure_message_loaded(MsgID, Opts) when ?IS_ID(MsgID) -> case hb_cache:read(MsgID, Opts) of {ok, LoadedMsg} -> LoadedMsg; + failure -> + failure; not_found -> throw({necessary_message_not_found, <<"/">>, MsgID}) end; diff --git a/src/hb_cache.erl b/src/hb_cache.erl index 6b945f6bc..98c9f0a63 100644 --- a/src/hb_cache.erl +++ b/src/hb_cache.erl @@ -468,12 +468,14 @@ store_read(Target, Path, Store, Opts) -> {store, Store} }), case hb_store:type(Store, ResolvedFullPath) of + failure -> failure; not_found -> not_found; simple -> ?event({reading_data, ResolvedFullPath}), case hb_store:read(Store, ResolvedFullPath) of {ok, Bin} -> {ok, Bin}; - not_found -> not_found + not_found -> not_found; + failure -> failure end; composite -> ?event({reading_composite, ResolvedFullPath}), diff --git a/src/hb_store_gateway.erl b/src/hb_store_gateway.erl index 47e3c98bf..cef532aa1 100644 --- a/src/hb_store_gateway.erl +++ b/src/hb_store_gateway.erl @@ -13,6 +13,7 @@ list(StoreOpts, Key) -> ?event(store_gateway, executing_list), case read(StoreOpts, Key) of not_found -> not_found; + failure -> failure; {ok, Message} -> {ok, hb_maps:keys(Message, StoreOpts)} end. @@ -23,6 +24,7 @@ type(StoreOpts, Key) -> ?event(store_gateway, executing_type), case read(StoreOpts, Key) of not_found -> not_found; + failure -> failure; {ok, Data} -> ?event({type, hb_private:reset(hb_message:uncommitted(Data, StoreOpts))}), IsFlat = lists:all( @@ -60,7 +62,7 @@ read(BaseStoreOpts, Key) -> case hb_store_remote_node:read_local_cache(StoreOpts, ID) of not_found -> ?event({gateway_read, {opts, StoreOpts}, {id, ID}, {subpath, Rest}}), - case hb_gateway_client:read(ID, StoreOpts) of + try hb_gateway_client:read(ID, StoreOpts) of {error, _} -> ?event({read_not_found, {key, ID}}), not_found; @@ -68,6 +70,16 @@ read(BaseStoreOpts, Key) -> ?event({read_found, {key, ID}}), hb_store_remote_node:maybe_cache(StoreOpts, Message), extract_path_value(Message, Rest, StoreOpts) + catch Class:Reason:Stacktrace -> + ?event( + gateway, + {read_failed, + {class, Class}, + {reason, Reason}, + {stacktrace, {trace, Stacktrace}} + } + ), + failure end; {ok, CachedMessage} -> extract_path_value(CachedMessage, Rest, StoreOpts) @@ -436,6 +448,23 @@ verifiability_test() -> ?event({verifying, {structured, Structured}, {original, Message}}), ?assert(hb_message:verify(Structured)). +%% @doc Reading an unsupported signature type transaction should fail +failure_to_process_message_test() -> + hb_http_server:start_node(#{}), + ?assertEqual(failure, + hb_cache:read( + <<"j0_mJMXG2YO4oRcOtjYsNoUJbN2TaKLo4nTtbhKqnEU">>, + #{ + store => + [ + #{ + <<"store-module">> => hb_store_gateway + } + ] + } + ) + ). + %% @doc Test that another HyperBEAM node offering the `~query@1.0' device can %% be used as a store. remote_hyperbeam_node_ans104_test() ->