Skip to content

workbook filter fails with special characters.  #1200

Open

Description

@VDFaller

Describe the bug
If my workbook has special character in it, my filter fails. I'm currently working around this but hoping that it can be fixed.

Versions
Details of your environment, including:

  • Tableau online
  • Python version: 3.9.12
  • tableauserverclient==0.23.4

To Reproduce

    with server.auth.sign_in(tableau_auth):
        wbs = server.workbooks.all()
        wbs.filter(name="T(L-F,SZ&V-MY) - PC")
        next(iter(wbs_iter)) # this will fail

Results

ServerResponseError: 

	400065: Bad Request
		None

Activity

  1. jacalata commented on Mar 14, 2023

    @jacalata
    Contributor

    Unfortunately you can't represent some characters in a search, but you can replace them with a wildcard.
    Specifically, I think it's "," and "&" that don't work. But this does:

    ` wb_name = "T(L-FSZV-MY) - PC"

        print("Searching for " + wb_name + "")
    
        for workbook in server.workbooks.filter(name=wb_name):
    
            print(workbook.name, workbook.id)
    

    `

    produces:
    Searching for T(L-F*SZ*V-MY) - PC
    T(L-F,SZ&V-MY) - PC b5d8b87f-3a3c-4787-83d4-6fd5cc2664db
    T(L-F^SZ|V-MY) - PC 44ea14d9-54e8-4b9f-9ec9-150fbea57b08

    https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_filtering_and_sorting.htm#filter-expression-notes

  2. added
    help wantedA user needs help, may be a mistake, a bug or a feature request
    on Mar 16, 2023
  3. jacalata commented on Apr 12, 2023

    @jacalata
    Contributor

    Should make sure our docs mention this limitation and workaround.

  4. VDFaller commented on Apr 20, 2023

    @VDFaller
    Author

    So would it make sense to add a replace_illegal_chars argument, hopefuly something pithier, to filter? I could try it if I get a hint or something. There's not a lot of doc strings in this repo.

    Maybe here?

    something like

    def filter(self, *invalid, **kwargs):
        if invalid:
            raise RuntimeError(f"Only accepts keyword arguments.")
        # special arg to allow for filtering on fields that contain illegal characters
        replace_illegal_characters = kwargs.pop("replace_illegal_characters", False)
        
        for kwarg_key, value in kwargs.items():
            field_name, operator = self._parse_shorthand_filter(kwarg_key)
            if replace_illegal_characters:
                value = self._replace_illegal_characters(value)
            self.request_options.filter.add(Filter(field_name, operator, value))
        return self
    
    def _replace_illegal_characters(self, value):
        """helper function to replace illegal characters in a string value for filtering"""
        if isinstance(value, str):
            return value.replace(",", "*").replace('&', '*')
        return value
  5. mtwalkup commented on Nov 16, 2023

    @mtwalkup

    Not sure if this applies here, but we've run into issues with commas in other queries. We got around them by replacing , with %5C%2C instead of just %2C. If I can figure out how to test a patch I may try it when I have some more time.

  6. mtwalkup commented on Nov 17, 2023

    @mtwalkup

    Disregard my last comment, I tried to make it work and forced a \ (%5C) before the comma still got a 400 error.

    However; just wanted to also note I am getting this same problem with a job filter.

    Edit: comma instead of command

  7. jacalata commented on Sep 20, 2024

    @jacalata
    Contributor

    We have a bunch of questions around filters, and will go through all of them to carefully document current behavior. that might turn into some work items if there are inconsistencies/gaps.

  8. github-actions commented on Aug 6, 2026

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. If this is still relevant, please comment to keep it open.

  9. added
    in-progressIssues that are in-progress of being fixed
    and removed on Aug 16, 2026
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

    docshelp wantedA user needs help, may be a mistake, a bug or a feature requestin-progressIssues that are in-progress of being fixed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions