Skip to content

'NoneType' object has no attribute 'total_available' for users.populate_groups #837

Closed

Description

@patawan

Describe the bug
I am attempting to get the number of groups a user is in using the code here: https://tableau.github.io/server-client-python/docs/api-ref#users for users.populate_groups

Versions
Details of your environment, including:

  • Tableau Server version: 3.9 (result from using server.version in Python script)
  • Tableau Server version: 2020.3.7 (listed under About Tableau Server)
  • Python version: 3.7.1
  • TSC library version: 0.15.0

To Reproduce
Code to reproduce:

with server.auth.sign_in(tableau_auth):
    all_users, pagination_item = server.users.get()
    print("\nThere are {} user on site: ".format(pagination_item.total_available))
    print([user.name for user in all_users])
    page_n = server.users.populate_groups(all_users[0])
    print("\nUser {0} is a member of {1} groups".format(all_users[0].name, page_n.total_available))
    print("\nThe groups are:")
    for group in all_users[0].groups :
        print(group.name)

Results

AttributeError: 'NoneType' object has no attribute 'total_available'

My initial thought is that our Tableau Server is not on a sufficient version to handle the request.

Activity

  1. bcantoni commented on Apr 23, 2021

    @bcantoni
    Contributor

    @patawan so far I'm puzzled by this one. At first I thought your user might not have enough permission to fetch the list of users (only site admins and server admins can do so), but if that was the case you'd get a 403 'user' isn't authorized to query users on site 'X' type of error.

    Can you confirm: using the same user as in your script, if you login to Tableau server web UI can you see a list of users?

    Your example is showing that server.users.get() is returning None for pagination_item. I guess one more thing you can try: is all_users also empty or are there entries there?

  2. patawan commented on Apr 23, 2021

    @patawan
    Author

    @bcantoni haha me too!

    I'm the user trying to access the list of users. I am an admin for this Tableau Site (not the whole server) and can see the full list of users on the Tableau server web UI.

    I altered the code a tiny bit: (also not sure why github doesn't like my code formatting)

    `with server.auth.sign_in(tableau_auth):
    all_users, pagination_item = server.users.get()

    print("\nThere are {} user on site: ".format(pagination_item.total_available))
    
    print([user.name for user in all_users])
    
    print(len(all_users))
    
    page_n = server.users.populate_groups(all_users[0])
    
    print("\nUser {0} is a member of {1} groups".format(all_users[0].name, page_n.total_available))
    
    print("\nThe groups are:")
    
    for group in all_users[0].groups :
    
        print(group.name)`
    

    I get the same error but this time it does show that all_users is not empty:
    Screenshot
    2021-04-23_14-30-34

    You can see my use case there in comments - I was able to find a workaround using Groups rather than users and generate a list of users with their Group Count. I'd be happy to share that if you think others will find it of use.

  3. SaravShah commented on Oct 12, 2021

    @SaravShah

    I'm running into the same exact issue. Was wondering if this was still being worked on?

  4. SaravShah commented on Oct 12, 2021

    @SaravShah

    I figured the issue out, @patawan if you do this

    temp_user = server.users.get_by_id(user_id)
              
    page_n = server.users.populate_groups(temp_user, req_options=None)
    print(temp_user.groups)
    for group in temp_user.groups:
        print(group.name)
    

    You should be able to get the user's groups. So grab the user, populate the user with groups, then access that original user object to get the group.s

  5. patawan commented on Oct 12, 2021

    @patawan
    Author

    Good find @SaravShah - thanks for following up!

  6. jacalata commented on Nov 8, 2021

    @jacalata
    Contributor

    Thanks for figuring this out @SaravShah - sounds like we need to update our docs or throw a clearer error message for this. Did you look at any specific documentation to work this out, or have a suggestion for us?

  7. added
    help wantedA user needs help, may be a mistake, a bug or a feature request
    on Nov 8, 2021
  8. self-assigned this
    on Jul 22, 2022
  9. removed
    help wantedA user needs help, may be a mistake, a bug or a feature request
    on Oct 8, 2022
  10. kramantab commented on Jan 27, 2023

    @kramantab
    Contributor

    Docs have been updated using the example provided in this issue

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions