Skip to content

fix: incorrect router hb_maps:get/3 Opts-as-fallback#705

Merged
samcamwilliams merged 1 commit intoedgefrom
audit/router-hbmaps-get
Mar 10, 2026
Merged

fix: incorrect router hb_maps:get/3 Opts-as-fallback#705
samcamwilliams merged 1 commit intoedgefrom
audit/router-hbmaps-get

Conversation

@charmful0x
Copy link

following the hb_maps:get/3 default misuse checks (#701), i patched another one in dev_router (Nearest strategy path)

issue

in choose/5 for <<"Nearest">>, this was using hb_maps:get(<<"wallet">>, Node, Opts) - which means Opts was being passed as default -> confusing errors if missing

patched to explicit handling with arity 4 + fail fast:

  Wallet =
      case hb_maps:get(<<"wallet">>, Node, not_found, Opts) of
          W when is_binary(W) -> W;
          not_found -> throw({error, wallet_not_found});
          _ -> throw({error, invalid_wallet})
      end,

also patched the same in preprocess/3, at user path extraction

            UserPath =
                case hb_maps:get(<<"path">>, Req, not_found, Opts) of
                    P when is_binary(P), byte_size(P) > 0 ->
                        P;
                    not_found ->
                        throw({error, missing_user_path});
                    _ ->
                        throw({error, invalid_user_path})
                end,

^ it was hb_maps:get(<<"path">>, Req, Opts)

all tests pass

  [done in 17.863 s]
=======================================================
  All 30 tests passed.

@samcamwilliams samcamwilliams merged commit 2193510 into edge Mar 10, 2026
@samcamwilliams samcamwilliams deleted the audit/router-hbmaps-get branch March 10, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants