Skip to content
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

fix: pop from empty list #1404

Merged
merged 5 commits into from
Jul 26, 2024
Merged

fix: pop from empty list #1404

merged 5 commits into from
Jul 26, 2024

Conversation

PatrickfBraz
Copy link
Contributor

Context

I am using the client to ingest Tableau metadata into the metadata platform called DataHub. When searching for metadata via GraphQL query, the client is returning the error shown in the message below. From my understanding of the code, this error can happen in 2 moments: at the end of pagination or at the beginning. In any case, the non-existence of the key sought within the json will cause extract_values to return an empty list and therefore trigger the IndexError when trying to call the pop method.

Traceback

line 713, in get_connection_objects
pages = self.tableau_source.server.metadata.paginated_query(query, variables=variables)["pages"] # type: ignore
File "/usr/local/lib/python3.10/site-packages/tableauserverclient/server/endpoint/endpoint.py", line 205, in wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/tableauserverclient/server/endpoint/metadata_endpoint.py", line 125, in paginated_query
has_another_page, cursor = get_page_info(results)
File "/usr/local/lib/python3.10/site-packages/tableauserverclient/server/endpoint/metadata_endpoint.py", line 45, in get_page_info
next_page = extract_values(result, "hasNextPage").pop()
IndexError: pop from empty list

Aditional information

The query we try to execute through the method client.server.metadata.paginated_query(...) is the following:

query customSQLDatasources($first: Int, $afterToken: String, $datasource_ids: [ID]) {
    customSQLTablesConnection(first: $first, after: $afterToken, filter: {idWithin: $datasource_ids}) {
        nodes {
            id
            name
            query
            columns {
                id
                name
                remoteType
                description
                referencedByFields {
                    datasource {
                        __typename
                        id
                        name
                        upstreamTables {
                            id
                            name
                            isEmbedded
                            database {
                                name
                            }
                            schema
                            fullName
                            connectionType
                        }
                        ... on PublishedDatasource {
                            projectName
                            luid
                        }
                        ... on EmbeddedDatasource {
                            workbook {
                                id
                                name
                                projectName
                                luid
                            }
                        }
                    }
                }
            }
            tables {
                id
                name
                isEmbedded
                database {
                    name
                }
                schema
                fullName
                connectionType
                description
                columns {
                    name
                    remoteType
                }
            }
            database {
                name
                connectionType
            }
        }
        pageInfo {
            hasNextPage
            endCursor
        }
        totalCount
    }
}

dependabot bot and others added 4 commits June 17, 2024 22:23
Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.0.7 to 2.2.2.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](urllib3/urllib3@2.0.7...2.2.2)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Copy link

Thanks for the contribution! Before we can merge this, we need @PatrickfBraz to sign the Salesforce Inc. Contributor License Agreement.

@PatrickfBraz
Copy link
Contributor Author

Signed
image

@jacalata jacalata changed the base branch from master to development June 21, 2024 05:35
@jacalata jacalata merged commit 84f2af4 into tableau:development Jul 26, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants