Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible UndefinedFunctionError in ExAws.InstanceMeta.request/2 #582

Conversation

ishikawa
Copy link
Contributor

@ishikawa ishikawa commented Aug 2, 2018

ExAws.Request.HttpClient behaviour specifies one callback function.

  @callback request(
              method :: http_method,
              url :: binary,
              req_body :: binary,
              headers :: [{binary, binary}, ...],
              http_opts :: term
            ) ::
              {:ok, %{status_code: pos_integer, body: binary}}
              | {:error, %{reason: any}}

But in ExAws.InstanceMeta.request/2, it expects HttpClient.reqeust/2. So an UndefinedFunctionError will be occurred if a custom HttpClient module doesn't implement request/2.

** (UndefinedFunctionError) function MyHTTPClient.request/2 is undefined or private
(my_project) MyHTTPClient.request(:get, "http://169.254.169.254/latest/meta-data/iam/security-credentials/")
(ex_aws) lib/ex_aws/instance_meta.ex:16: ExAws.InstanceMeta.request/2
(ex_aws) lib/ex_aws/instance_meta.ex:58: ExAws.InstanceMeta.instance_role_credentials/1
(ex_aws) lib/ex_aws/instance_meta.ex:64: ExAws.InstanceMeta.security_credentials/1
(ex_aws) lib/ex_aws/config/auth_cache.ex:58: ExAws.Config.AuthCache.refresh_config/2
(ex_aws) lib/ex_aws/config/auth_cache.ex:33: ExAws.Config.AuthCache.handle_call/3
(stdlib) gen_server.erl:661: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:690: :gen_server.handle_msg/6

This PR fixes the issue and add a simple test.

@benwilson512 benwilson512 merged commit d7ae874 into ex-aws:master Aug 2, 2018
@benwilson512
Copy link
Contributor

Thanks!

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.

None yet

2 participants