When C* authentication is enabled and Credentials are not supplied a NoHostAvaiableException is thrown where the Errors exception entry has a value of ArgumentNullException with a non-meaningful message

Description

When C* authentication is enabled (authenticator is PasswordAuthenticator and authorizer is CassandraAuthorizer) and the Cluster.WithCredentials is NOT called when building the cluster object upon the call to connect a NoHostAvaiableException is thrown with a message of "None of the hosts tried for the query are available (tried: 192.168.117.128)" and the Errors property has an entry where the exception is ArgumentNullException with message "String reference not set to an instance of a String. Parameter name: s". Attached is the details of both exceptions.

Environment

Windows, C* 2.0.9

Activity

Show:
Jorge Bay Gondra
October 16, 2014, 2:57 PM

There is a covering test for this and it is passing.

The inner error is: Cassandra.AuthenticationException: Authentication error on host x.x.x.x: Host x.x.x.x requires authentication, but no authenticator found in Cluster configuration.

I see in the exception detail that the exception is thrown from the PlainTextAuthenticator constructor, maybe you are providing null values to the PlainTextAuthProvider, is that the case? If so, in that case the exception seems OK. Maybe we could throw an exception when trying to create a PlainTextAuthProvider with null username and/or password.

Richard Andersen
October 16, 2014, 3:29 PM

we are not using the PlainTextAuthenticator class. Below is the code that demos this exception:

var connectionStringV1 = "Contact Points=10.200.240.251";//"Contact Points=127.0.0.1"; WIN-DCE12X-3M

using (var clusterV1 = Cluster
.Builder()
.WithConnectionString(connectionStringV1)
.WithoutRowSetBuffering()
.Build())
using (var sessionV1 = clusterV1.Connect())
{
sessionV1.Execute("select * from readonly.document").Dump();
}

Jorge Bay Gondra
October 17, 2014, 8:50 AM

Thanks for the info. Builder.WithConnectionString() was building an auth provider with empty credentials when there weren't provided.

Now it doesn't do that and also check for null values if provided.

I've included 4 unit tests.

Jorge Bay Gondra
October 17, 2014, 8:54 AM
Edited

To clarify, in the example you provided you should now get the AuthenticationException with message "Host x.x.x.x requires authentication, but no authenticator found in Cluster configuration" as it is supposed to.

Fixed

Assignee

Jorge Bay Gondra

Reporter

Richard Andersen

Labels

None

Reproduced in

None

PM Priority

None

Fix versions

External issue ID

None

Doc Impact

None

Reviewer

None

Pull Request

None

Epic Link

None

Sprint

None

Pull Requests

None

Size

None

Components

Affects versions

Priority

Minor
Configure