Confusing errors raised when missing configuration
Environment
- Elixir & Erlang versions (elixir --version): Erlang/OTP 23 [erts-11.2.2.2] [source] [64-bit] [smp:6:6] [ds:6:6:10] [async-threads:1] [hipe]
Elixir 1.11.4 (compiled with Erlang/OTP 23)
-
ExAws version
mix deps |grep ex_aws -
ex_aws (Hex package) (mix) locked at 2.2.3 (ex_aws) 8ddf1da9
-
ex_aws_s3 (Hex package) (mix) locked at 2.2.0 (ex_aws_s3) 15175c61
-
ex_aws_ses (Hex package) (mix) locked at 2.1.1 (ex_aws_ses) 86c8a7b1
-
HTTP client version. IE for hackney do
mix deps | grep hackney -
hackney 1.17.4 (Hex package) (rebar3) locked at 1.17.4 (hackney) de16ff49
Current behavior
I was running in an environment where access_key_id, secret_access_key, and region were not configured properly.
When running test in this env ex_aws gives confusing error which is hard to decipher:
** (exit) exited in: GenServer.call(ExAws.Config.AuthCache, {:refresh_auth, %{}}, 30000)
** (EXIT) an exception was raised:
** (KeyError) key :json_codec not found in: %{}
(ex_aws 2.2.3) lib/ex_aws/instance_meta.ex:66: ExAws.InstanceMeta.instance_role_credentials/1
(ex_aws 2.2.3) lib/ex_aws/instance_meta.ex:72: ExAws.InstanceMeta.security_credentials/1
(ex_aws 2.2.3) lib/ex_aws/config/auth_cache.ex:116: ExAws.Config.AuthCache.refresh_auth_now/2
(ex_aws 2.2.3) lib/ex_aws/config/auth_cache.ex:45: ExAws.Config.AuthCache.handle_call/3
(stdlib 3.14.2.1) gen_server.erl:715: :gen_server.try_handle_call/4
(stdlib 3.14.2.1) gen_server.erl:744: :gen_server.handle_msg/6
(stdlib 3.14.2.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Expected behavior
I would expect a user friendly error which would point to missing keys in configuration.
Yep, I'd definitely agree that improved errors would make some of this stuff a lot easier. I've hit almost exactly this one myself. PRs to that effect would be most welcome.