ownerName filter does not return items for workbooks, datasources, flows, projects, views, metrics
Describe the bug Providing the owerName filter to an endpoint never returns any items.
Versions Details of your environment, including:
- Tableau Server Version - 2020.3.8, 2021.3.0
- Python Version - 3.8.10
- Tableauserverclient version - 0.16.0
To Reproduce EDIT: Edited the reproduction code to reflect more handling of commas and spaces. None of the combinations produced yield a result.
from itertools import product
import os
from dotenv import load_dotenv
import tableauserverclient as TSC
load_dotenv()
server = TSC.Server(os.environ["SERVER_ADDRESS"], True)
auth = ...
server.auth.sign_in(auth)
prefix_domain = lambda name, domain: f'{domain}\\{name}'
suffix_domain = lambda name, domain: f'{name}@{domain}'
just_name = lambda name, domain: name
# Comma treatments
remove_comma = lambda name: name.replace(',', '')
first_last = lambda name: ' '.join(name.split(', ')[::-1])
url_encode_comma = lambda name: name.replace(',', '%2C')
backslash_comma = lambda name: name.replace(',', '\\,')
backslash_url_escaped_comma = lambda name: name.replace(',', '\\%2C')
url_encode_escape_comma = lambda name: name.replace(',', '%5C%2C')
no_op = lambda name: name
# Space treatments
remove_space = lambda name: name.replace(' ', '')
url_encode_space = lambda name: name.replace(' ', '%20')
url_encode_escape_space = lambda name: name.replace(' ', '%5C%20')
url_encode_plus_space = lambda name: name.replace(' ', '+')
url_encode_plus_escape_space = lambda name: name.replace(' ', '%5C+')
user: TSC.UserItem = server.users.get_by_id(server.user_id)
email = user.email
username = user.name
domain = user.domain_name
formats = [prefix_domain, suffix_domain, just_name]
user_names = [user.fullname, email, username]
# control
commas = [no_op, remove_comma, first_last, url_encode_comma, backslash_comma, backslash_url_escaped_comma, url_encode_escape_comma]
# control
spaces = [no_op, remove_space, url_encode_space, url_encode_escape_space, url_encode_plus_space, url_encode_plus_escape_space]
# control
string_methods = [str.strip, str.capitalize, str.casefold, str.lower, str.title, str.upper]
endpoints = ['workbooks'] #, 'projects', 'datasources', 'flows', 'views']
for combo in product(formats, user_names, commas, spaces, string_methods, string_methods, endpoints):
# edit - Added check for case sensitivity on domain
func, name, comma, spaces, method, dom_method, endpoint = combo
name = comma(name)
name = method(name)
name = spaces(name)
dom = dom_method(domain)
name = func(name, dom)
reqopts = TSC.RequestOptions()
reqopts.filter.add(
TSC.Filter(
TSC.RequestOptions.Field.OwnerName,
TSC.RequestOptions.Operator.Equals,
name
)
)
endpoint = getattr(server, endpoint)
try:
items, _ = endpoint.get(reqopts)
except TSC.ServerResponseError:
continue
if len(items) > 0:
print(name)
Results No results are ever printed, yet at least some combination of that should work.
NOTE: Be careful not to post user names, passwords, auth tokens or any other private or sensitive information.
I should add that for that site, I own multiples for projects, workbooks, data sources, views, and flows, so at least something should have returned.
So for the record, you are supposed to search by user.fullname, which shouldn't need any changing to use with tsc. I believe you aren't actually trying that as is in the code above, are you?
On my server that is a value looking like "First LastName", but from the first_last and last_first string handling you've got, I'm guessing it's not like that on your server? a) does it work if you pass in user.fullname directly? b) can you share an example of user.fullname from your server?
On my server, it is "LastName, First". So mine would appear as "Woods, Jordan". When I try passing in user.fullname directly, I get back ServerResponse Error: 400065: Bad Request. If I try changing it to the urllib.parse.quote_plus version, or otherwise escaping the comma, it does not return results either.
Per the Filtering and Sorting docs:
Note: Filter expressions can’t contain ampersand (&) or comma (,) characters because these characters are used as field expression separators. This is true even if those characters are encoded.
Would it be possible to enable it server side such that commas and ampersands escaped similar to how salesforce does it will work?
E.G.
server.flows.filter(owner_name="Woods%5c%2c+Jordan")