Skip to content

add cursor based pagination - #91

Open
yannickbetou-dku wants to merge 6 commits into
masterfrom
bug/dss14-sc-337638--api-connect-cannot-paginate-using-cusor
Open

add cursor based pagination#91
yannickbetou-dku wants to merge 6 commits into
masterfrom
bug/dss14-sc-337638--api-connect-cannot-paginate-using-cusor

Conversation

@yannickbetou-dku

@yannickbetou-dku yannickbetou-dku commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

sc-337638

@yannickbetou-dku yannickbetou-dku added bug Something isn't working enhancement New feature or request labels Aug 20, 2026
…--api-connect-cannot-paginate-using-cusor' into bug/dss14-sc-337638--api-connect-cannot-paginate-using-cusor
Comment thread python-lib/pagination.py Outdated
Comment on lines 31 to 61
@@ -34,17 +40,23 @@ def configure_paging(self, config=None, skip_key=None,
if next_page_url_base:
next_page_url_base = next_page_url_base.strip('/')
self.next_page_url_base = next_page_url_base
elif self.pagination_type == "cursor":
self.cursor_next_token_path = config.get("cursor_next_token_path", cursor_next_token_path)
self.cursor_query_param = config.get("cursor_query_param", cursor_query_param)
self.cursor_initial_token = config.get("cursor_initial_token", cursor_initial_token)
elif self.pagination_type in ["offset", "page"]:
self.skip_key = config.get("skip_key", skip_key)
logger.info("configure_paging: self.pagination_type='{}', self.next_page_key='{}', self.next_page_url_base='{}', self.skip_key='{}'".format(
self.pagination_type, self.next_page_key, self.next_page_url_base, self.skip_key
logger.info("configure_paging: self.pagination_type='{}', self.next_page_key='{}', self.next_page_url_base='{}', self.skip_key='{}', self.cursor_next_token_path='{}', self.cursor_query_param='{}', self.cursor_initial_token='{}'".format(
self.pagination_type, self.next_page_key, self.next_page_url_base, self.skip_key, self.cursor_next_token_path, self.cursor_query_param, self.cursor_initial_token
))
if self.pagination_type == "next_page":
self.update_next_page = self.update_next_page_link
elif self.pagination_type == "offset":
self.update_next_page = self.update_next_page_offset
elif self.pagination_type == "page":
self.update_next_page = self.update_next_page_per_page
elif self.pagination_type == "cursor":
self.update_next_page = self.update_next_page_cursor
else:
self.update_next_page = self.update_next_page_default

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: for readability, I would split this method into smaller ones since there are only if .. elif in the implementation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rationalized a bit the method but I'm not sur splitting it would make it a lot clearer.

Comment thread python-lib/pagination.py

if self.cursor_next_token_path and self.cursor_query_param:
self.cursor_query_param_value = extract_key_using_json_path(data, self.cursor_next_token_path)
logger.info("update_next_page_cursor:{}".format({self.cursor_query_param_value}))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest debug

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's consistent with the other pagination type, I would agree conceptually but it was useful when debugging the issue initially

Comment thread python-lib/pagination.py
return ret
if self.pagination_type == "cursor":
ret = (self.cursor_query_param_value is not None) and (self.cursor_query_param_value != "")
logger.info("has_next_page:cursor_next_token_path={} cursor_query_param={} cursor_query_param_value={} -> {}".format(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, I would put debug

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same than previous

Comment on lines +92 to +94
cursor_next_token_path = endpoint.get("cursor_next_token_path")
cursor_query_param = endpoint.get("cursor_query_param")
cursor_initial_token = format_template(endpoint.get("cursor_initial_token"), **self.presets_variables)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why only intital_token supports variables and the others don't?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see how it would be useful for the others, initial token has a good chance to be stored within contextual variables.

@duynghiatran duynghiatran left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants