Skip to content

Misuse or incorrect type for aws_credentials_provider:options() #70

@dw-kihara

Description

@dw-kihara

Hello,

I am trying to use this library and I found a problem with aws_credentials_provider:options().

According to the type declaration this type appear to be a nested map as shown below:

%% type declaration in aws_credentials_provider
%% -type options() :: #{provider() => map()}.

%% maybe like this
Options = #{
    aws_credentials_file => #{
        credential_path => "/path/to/aws/",
        profile => "my_profile"
    }
}.

However, in practice, the variable needs to be a flat map without a provider name, as shown in this example:

%% code in aws_credentials_file
-spec get_file_path(aws_credentials_provider:options()) -> {error, any()} | string().
get_file_path(Options) ->
  case maps:get(credential_path, Options, undefined) of
    undefined -> maybe_add_home("/.aws/");
    Path -> Path
  end.

Possible fixes:

  1. Keep the current code and modify aws_credentials_provider:options() type to be a flat map to match current usage.
  2. Change option values and usage to match the type declaration.

Method 1 is easier but makes it much harder to have different options for different providers in the future.
Method 2 is cleaner but breaks current library users, though some compatibility compromises could be made.

If I could choose, I would take method 2 with special credentials_path and profile options to maintain compatibility for current aws_credentials_file users.
(Luckily, there are no other usage except for those two options in aws_credentials_file.)

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions