markhoerth / dremio_client

Apache License 2.0
31 stars 25 forks source link

delete_catalog may fail if tag contains special characters #299

Open akravchuk1 opened 2 years ago

akravchuk1 commented 2 years ago

Description

Pulling information about catalog item and then deleting an item using id and tag returned may fail if tag contains special characters vds_json = client.catalog_item(None, vds_path.split("/")) client.delete_catalog(vds_json["id"], tag=vds_json["tag"]) In some cases characters in tag will break URL and error similar to this is returned

ERROR - exception:unknown error: 409 Client Error: Conflict for url:

https://dremio-test.expedia.biz:443/api/v3/catalog/5fda0e34-ab57-42b9-a800-5c3fa9169112?tag=GRjH+GRCIhM=

What I Did

It is easy to fix by urlencoding the tag before passing to the function
            vds_json = client.catalog_item(None, vds_path.split("/"))
            encoded_tag = urllib.parse.quote(vds_json["tag"], safe="")
            client.delete_catalog(vds_json["id"], tag=encoded_tag)

However, correct fix is probably to encode it if needed in the client library, before passing to Dremio 
https://github.com/rymurr/dremio_client/blob/5c2052d02abec1777bda8f985cebe9c50e040de9/dremio_client/model/endpoints.py#L561