10000 Delete tag with special characters like '#' does not work · Issue #675 · tableau/server-client-python · GitHub
[go: up one dir, main page]

Skip to content

Delete tag with special characters like '#' does not work #675

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

Open
tv-terminator opened this issue Aug 25, 2020 · 5 comments
Open

Delete tag with special characters like '#' does not work #675

tv-terminator opened this issue Aug 25, 2020 · 5 comments

Comments

@tv-terminator
Copy link

I found that if the tag contains encodable characters such as '#' (which is quite commonly used for tagging!), the delete tag request neither succeeds nor throws an exception.

url = "{0}/{1}/tags/{2}".format(baseurl, resource_id, tag_name)

@bcantoni
Copy link
Contributor

@tv-terminator there could be an issue there (I think we have or had a similar bug with encoding special characters). Can you give a fuller code snippet example of how you're trying to delete tags? Also what type of resource are the tags associated with?

@tv-terminator
Copy link
Author

I have tried both workbooks & datasources; ended up with same result. Heres a full log with code:

`# w = workbook_item, t = tableau connection/hook

w=t.workbooks_get(get_by_content_url='POC')[0]
w
<tableauserverclient.models.workbook_item.WorkbookItem object at 0x7f1116314e10>
w.tags
set()
w.tags.add('#test')
w.tags
{'#test'}
t.workbooks_update(w)
[2020-08-28 19:43:18,196] {{resource_tagger.py:47}} INFO - Updated tags to {'#test'}
[2020-08-28 19:43:18,283] {{workbooks_endpoint.py:89}} INFO - Updated workbook item (ID: xxxxxx-xxxxxx-xxxxx-xxxxx)
<tableauserverclient.models.workbook_item.WorkbookItem object at 0x7f1118fa3f28>
w=t.workbooks_get(get_by_content_url='POC')[0]
w.tags
{'#test'}
w.tags.remove('#test')
w.tags
set()
t.workbooks_update(w)
[2020-08-28 19:44:10,195] {{resource_tagger.py:47}} INFO - Updated tags to set()
[2020-08-28 19:44:10,259] {{workbooks_endpoint.py:89}} INFO - Updated workbook item (ID: xxxxxx-xxxxxx-xxxxx-xxxxx)
<tableauserverclient.models.workbook_item.WorkbookItem object at 0x7f1116f73400>
w=t.workbooks_get(get_by_content_url='POC')[0]
w.tags
{'#test'}
`

Works fine with a plain text tag:
`

w.tags.add('test')
w.tags
{'#test', 'test'}
t.workbooks_update(w)
[2020-08-28 19:47:38,117] {{resource_tagger.py:47}} INFO - Updated tags to {'#test', 'test'}
[2020-08-28 19:47:38,194] {{workbooks_endpoint.py:89}} INFO - Updated workbook item (ID: xxxxxx-xxxxxx-xxxxx-xxxxx)
<tableauserverclient.models.workbook_item.WorkbookItem object at 0x7f1116791ba8>
w=t.workbooks_get(get_by_content_url='POC')[0]
w.tags
{'#test', 'test'}
w.tags.remove('test')
w.tags
{'#test'}
t.workbooks_update(w)
[2020-08-28 19:48:19,445] {{resource_tagger.py:47}} INFO - Updated tags to {'#test'}
[2020-08-28 19:48:19,519] {{workbooks_endpoint.py:89}} INFO - Updated workbook item (ID: xxxxxx-xxxxxx-xxxxx-xxxxx)
<tableauserverclient.models.workbook_item.WorkbookItem object at 0x7f1116bf1ac8>
w=t.workbooks_get(get_by_content_url='POC')[0]
w.tags
{'#test'}
`

@bcantoni bcantoni changed the title Delete tag does not work Delete tag with special characters like '#' does not work Sep 1, 2020
@bcantoni bcantoni added the bug label Sep 1, 2020
@bcantoni
Copy link
Contributor
bcantoni commented Sep 1, 2020

Thanks @tv-terminator for the repro steps. I can confirm this is a bug and your pointer to resource_tagger.py is where we are not properly quoting the tag.

Adding new #test tag works, put method:

DEBUG:urllib3.connectionpool:https://10ax.online.tableau.com:443 "PUT /api/3.9/sites/MY-SITE-IT/workbooks/MY-WORKBOOK-ID/tags HTTP/1.1" 200 202

Deleting the #test tag does not work, delete method throws a 405 error because "#test" is dropped from the URL:

DEBUG:urllib3.connectionpool:https://10ax.online.tableau.com:443 "DELETE /api/3.9/sites/MY-SITE-IT/workbooks/MY-WORKBOOK-ID/tags/ HTTP/1.1" 405 377
DEBUG:tableau.endpoint:b'<?xml version=\'1.0\' encoding=\'UTF-8\'?><tsResponse xmlns="http://tableau.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api http://tableau.com/api/ts-api-3.9.xsd"><error code="405000"><summary>Method Not Allowed</summary><detail>The HTTP method \'DELETE\' is not supported for the given resource</detail></error></tsResponse>'

Trying to delete a tag foo#bar shows the similar issue, with everything from the pound sign being dropped in the URL resulting in a 404:

DEBUG:urllib3.connectionpool:https://10ax.online.tableau.com:443 "DELETE /api/3.9/sites/MY-SITE-IT/workbooks/MY-WORKBOOK-ID/tags/foo HTTP/1.1" 404 342
DEBUG:tableau.endpoint:b'<?xml version=\'1.0\' encoding=\'UTF-8\'?><tsResponse xmlns="http://tableau.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api http://tableau.com/api/ts-api-3.9.xsd"><error code="404007"><summary>Resource Not Found</summary><detail>Tag \'foo\' could not be found.</detail></error></tsResponse>'

There are a few other open bugs around attributes with special characters, so hopefully we can resolve some of these together.

@tv-terminator
Copy link
Author

Awesome! Thanks @bcantoni !

@bcantoni
Copy link
Contributor
bcantoni commented Sep 2, 2020

Similar bugs related to encoding include #578, #516 and #418

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0