Skip to content

Sign in with http_options set will fail #1116

Closed

Description

@bcantoni

Describe the bug
Signing in to a server when any http_options have been set in the TSC.Server object will result in an exception:

KeyError: 'X-TableauServerClient-Version'

Versions
TSC library versions v0.21 and v0.22 have the issue. Version v0.19.1 works correctly.

To Reproduce
Include any http_options while creating the TSC.Server object:

server = TSC.Server('https://10ax.online.tableau.com', use_server_version=True, http_options={"verify": False})
server.auth.sign_in(tableau_auth)

Workaround: use TSC v0.19.1 instead.

Results

Traceback (most recent call last):
  File "/Users/brian/github/server-client-python/pat-login.py", line 17, in <module>
    server = TSC.Server('https://10ax.online.tableau.com', use_server_version=True, http_options={"verify": False})
  File "/Users/brian/github/server-client-python/tableauserverclient/server/server.py", line 101, in __init__
    self.add_http_version_header()
  File "/Users/brian/github/server-client-python/tableauserverclient/server/server.py", line 112, in add_http_version_header
    if not self._http_options[client_version_header]:
KeyError: 'X-TableauServerClient-Version'

Activity

  1. t8y8 commented on Sep 22, 2022

    @t8y8
    Contributor

    https://github.com/tableau/server-client-python/pull/1075/files#diff-baff71702721406ed2f46c06b280ce8c2d463b77a5aa33badcb548d93ca31a7aR110 is the commit where it broke, I think you can just change it to...

    def add_http_version_header(self):
        if client_version_header not in self._http_options:
            self._http_options[client_version_header] = __TSC_VERSION__

    That's a slightly more idiomatic way to do a key check in a dict.

    The following works too, if you want the smallest possible fix:

    def add_http_version_header(self):
        if not self._http_options.get(client_version_header):
            self._http_options.update({client_version_header: __TSC_VERSION__})

    It's probably better to put those module level constants as ALL_CAPS or _PREFIXED given they're not really useful outside this context

  2. bcantoni commented on Sep 26, 2022

    @bcantoni
    ContributorAuthor

    I tested with current development branch with Jac's fix merged and it looks correct now.

  3. bcantoni commented on Sep 28, 2022

    @bcantoni
    ContributorAuthor

    This is fixed now in release 0.23.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions