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

Confusing interface of no_credentials() for config #971

Closed
ivan-kiselev opened this issue Nov 24, 2023 · 6 comments
Closed

Confusing interface of no_credentials() for config #971

ivan-kiselev opened this issue Nov 24, 2023 · 6 comments
Assignees
Labels
bug This issue is a bug. documentation This is a problem with documentation p2 This is a standard priority issue pending-release This issue will be fixed by an approved PR that hasn't been released yet.

Comments

@ivan-kiselev
Copy link

Describe the bug

So, I am not quite sure it's a bug or intended, but I am trying to use locally running DynamoDB provided by NoSQL workbench for integration testing and general development loop, thus I need to connect SDK to the http://localhost:8000 instance of DynamoDB.

I tried to play with no_credentials() thing for a little while, but it doesn't really workout with the following error:

called `Result::unwrap()` on an `Err` value: DispatchFailure(DispatchFailure { source: ConnectorError { kind: Other(None), source: NoMatchingAuthScheme, connection: Unknown } })

And in the same time, shall I introduce silly Credentials provider, it will work alright.

use aws_sdk_dynamodb::config::Credentials;

fn create_my_credential_provider() -> Credentials {
    Credentials::new("example", "example", None, None, "example")
}

#[tokio::main]
async fn main() {
    tracing_subscriber::fmt::init();
    let cfg = aws_config::defaults(aws_config::BehaviorVersion::latest())
        .endpoint_url("http://localhost:8000")
        .region("eu-west-1")
        // .no_credentials() <- doesn't work
        .credentials_provider(create_my_credential_provider()) // <- works, but kinad silly and feels like should be covered by .no_credentials() instead
        .load()
        .await;

    let cfg = aws_sdk_dynamodb::Config::new(&cfg);
    let client = aws_sdk_dynamodb::Client::from_conf(cfg);
    let response = client.list_tables().send().await.unwrap();
    for table in response.table_names().iter() {
        println!("Found table {}", table)
    }
}

Now, as much as there's though seemingly silly, but robust workaround, it does feel that implementation of .no_credentials() is somehow incomplete and this use-case shall be covered by it.

As in, I, as a user of the sdk, when seen this method - it seemed natural for me to assume that it is exactly what I need, but somehow it was not.

Also, if I am doing something fundamentally wrong, I am happy to stand corrected.

Expected Behavior

Either no_credentials() on on aws_config::ConfigLoader removes any checks/validations for authentication from any client build with such config, or maybe it shall be renamed to something a bit more narrow if it was not the intent for the method.

Current Behavior

For dynamodb, at least, when building client with .no_credentials() config, one gets an error:

called `Result::unwrap()` on an `Err` value: DispatchFailure(DispatchFailure { source: ConnectorError { kind: Other(None), source: NoMatchingAuthScheme, connection: Unknown } })

Reproduction Steps

Run the following snippet with locally running DynamoDB

#[tokio::main]
async fn main() {
    tracing_subscriber::fmt::init();
    let cfg = aws_config::defaults(aws_config::BehaviorVersion::latest())
        .endpoint_url("http://localhost:8000")
        .region("eu-west-1")
        .no_credentials() <- doesn't work
        .load()
        .await;

    let cfg = aws_sdk_dynamodb::Config::new(&cfg);
    let client = aws_sdk_dynamodb::Client::from_conf(cfg);
    let request = client.list_tables().send().await.unwrap();
    for table in request.table_names().iter() {
        println!("Found table {}", table)
    }
}

Possible Solution

No response

Additional Information/Context

No response

Version

[dependencies]
aws-config = "1.0.0"
aws-sdk-dynamodb = { version = "0.39.0", features = ["behavior-version-latest"] }
tokio = { version = "1.34.0", features = ["full"] }
tracing-subscriber = "0.3.18"



### Environment details (OS name and version, etc.)

MacOS 14.1.1 (23B81) ❯ uname -a Darwin hehe.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct  9 21:28:31 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T8112 arm64

### Logs

_No response_
@ivan-kiselev ivan-kiselev added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 24, 2023
@rcoh
Copy link
Contributor

rcoh commented Nov 25, 2023

Dynamo isn't configured to work with no credentials (this is required to be modeled behavior). As the docs of no_credentials say, this is a very specific behavior that actually fully disables authentication (when allowed by the model).

Another option is Credentials::for_tests()

note that this will require enabling the test-util feature

@rcoh
Copy link
Contributor

rcoh commented Nov 25, 2023

We should clarify the documentation of no_credentials, at the very least.

@rcoh rcoh added documentation This is a problem with documentation and removed needs-triage This issue or PR still needs to be triaged. labels Nov 25, 2023
@ivan-kiselev
Copy link
Author

Well, one would use absence of auth in testing purposes anyways, so enabling test-util is completely fine.

Can confirm that Credentials::for_tests() works just fine.

@rcoh rcoh self-assigned this Dec 1, 2023
@jdisanti
Copy link
Contributor

jdisanti commented Dec 4, 2023

The fix for this has been merged and will go out in an upcoming release.

@jdisanti jdisanti added the pending-release This issue will be fixed by an approved PR that hasn't been released yet. label Dec 4, 2023
@jmklix jmklix added the p2 This is a standard priority issue label Dec 8, 2023
@jdisanti
Copy link
Contributor

The fix for this went out in the December 14th release.

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. documentation This is a problem with documentation p2 This is a standard priority issue pending-release This issue will be fixed by an approved PR that hasn't been released yet.
Projects
None yet
Development

No branches or pull requests

4 participants