Skip to content

fix: hb_maps:get defaults and defaults validation#701

Open
charmful0x wants to merge 6 commits intoimpr/secure-actionsfrom
audit/mint-math
Open

fix: hb_maps:get defaults and defaults validation#701
charmful0x wants to merge 6 commits intoimpr/secure-actionsfrom
audit/mint-math

Conversation

@charmful0x
Copy link

@charmful0x charmful0x commented Feb 27, 2026

addressed #688 (comment) in a separate PR due to wider scope

TLDR

there was mixed hb_maps:get/3 and hb_maps:get/4 usage where some get/3 calls passed Opts as the default value instead of using arity 4 -- patched in:

  • dev_pot_test_vectors
  • dev_mint_math
  • dev_mint_stats

also added a fail fast hb_util:safe_int/1 wrapper (dev_mint_math:required_int/1) to replace previous hb_util:int/1 usage on required numeric fields, so failures now throw typed errors instead of generic crashes (as the get/4 defaults are now correctly in place)

%% @doc Fail Fast wrapper for hb_util:safe_int.
required_int(Value) ->
    case hb_util:safe_int(Value) of
        {ok, SafeInt} -> SafeInt;
        _ -> throw({error, required_int_parse_failure})
    end.

tests run:

rebar3 eunit --module=dev_mint_test_vectors
rebar3 eunit --module=dev_pot_test_vectors
rebar3 eunit --module=dev_pot_math_props
rebar3 eunit --module=dev_pot_props

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.

1 participant