ex-aws / ex_aws

A flexible, easy to use set of clients AWS APIs for Elixir
https://hex.pm/packages/ex_aws
MIT License
1.29k stars 529 forks source link

Confusing errors raised when missing configuration #797

Open Maxim-Filimonov opened 3 years ago

Maxim-Filimonov commented 3 years ago

Environment

Elixir 1.11.4 (compiled with Erlang/OTP 23)

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.

bernardd commented 3 years ago

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.