Skip to content

ssl_client_cert passed is being assigned to proxies in Cursor object #300

@shek1608

Description

@shek1608

In function cursor of Class Connection, an object of class Cursor is created with ssl_client_cert and proxies as 7th and 8th parameters respectively as seen here:
https://github.com/druid-io/pydruid/blob/master/pydruid/db/api.py#L169-L177

The Cursor object's init has the 2 parameters exchanged, effectively putting ssl_client_cert's value into proxies and vice versa as seen here:
https://github.com/druid-io/pydruid/blob/master/pydruid/db/api.py#L199-L208

Example use case from python 3.8 using sqlalchemy:

from sqlalchemy import *
from sqlalchemy.engine import create_engine
engine = create_engine('druid+https://<user>@<host>:<port>/druid/v2/sql', connect_args = {'ssl_client_cert':('<path_to_cert>','<path_to_key>')})
conn = engine.connect();
res = conn.execute('SELECT "<column>" from <table> limit 10');

Having a print statement in the init function will show the value:

print("In cursor's init - ssl_client_cert= {} ; proxies= ".format(ssl_client_cert, proxies))

results in:

In cursor's init - ssl_client_cert= None ; proxies= ('<path_to_cert>','<path_to_key>')

The error thrown for my use case for the conn.execute line was:

  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 711, in merge_environment_settings
    no_proxy = proxies.get('no_proxy') if proxies is not None else None
AttributeError: 'tuple' object has no attribute 'get'

The above led me to debug the code and find this.

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