-
Notifications
You must be signed in to change notification settings - Fork 74
airbyte pull more in a single page #1180
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -267,7 +267,10 @@ def get_sources(workspace_id: str) -> List[Dict]: | |
| if not isinstance(workspace_id, str): | ||
| raise HttpError(400, "Invalid workspace ID") | ||
|
|
||
| res = abreq("sources/list", {"workspaceId": workspace_id}) | ||
| # TODO: move this to paginated apis | ||
| res = abreq( | ||
| "sources/list", {"workspaceId": workspace_id, "pageSize": 100, "sortKey": "actorName_asc"} | ||
| ) | ||
| if "sources" not in res: | ||
| logger.error("Sources not found for workspace: %s", workspace_id) | ||
| raise HttpError(404, "sources not found for workspace") | ||
|
|
@@ -528,7 +531,11 @@ def get_destinations(workspace_id: str) -> dict: | |
| if not isinstance(workspace_id, str): | ||
| raise HttpError(400, "workspace_id must be a string") | ||
|
|
||
| res = abreq("destinations/list", {"workspaceId": workspace_id}) | ||
| # TODO: move this to paginated apis | ||
| res = abreq( | ||
| "destinations/list", | ||
| {"workspaceId": workspace_id, "pageSize": 100, "sortKey": "actorName_asc"}, | ||
| ) | ||
|
Comment on lines
+534
to
+538
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same pagination limitation applies here. Like Consider applying the same pagination solution as suggested for |
||
| if "destinations" not in res: | ||
| logger.error("Destinations not found for workspace: %s", workspace_id) | ||
| raise HttpError(404, "destinations not found for this workspace") | ||
|
|
@@ -677,7 +684,11 @@ def get_webbackend_connections(workspace_id: str) -> dict: | |
| if not isinstance(workspace_id, str): | ||
| raise HttpError(400, "workspace_id must be a string") | ||
|
|
||
| res = abreq("web_backend/connections/list", {"workspaceId": workspace_id}) | ||
| # TODO: move this to paginated apis | ||
| res = abreq( | ||
| "web_backend/connections/list", | ||
| {"workspaceId": workspace_id, "pageSize": 100, "sortKey": "connectionName_asc"}, | ||
| ) | ||
|
Comment on lines
+687
to
+691
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pagination limitation in web backend connections. This function has the same critical issue: workspaces with more than 100 connections will have incomplete data. The sort key Note that unlike the other functions, this returns 🤖 Prompt for AI Agents |
||
| if "connections" not in res: | ||
| error_message = f"connections not found for workspace: {workspace_id}" | ||
| logger.error(error_message) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed page size can cause silent data truncation.
Setting
pageSize: 100without pagination logic means workspaces with more than 100 sources will return incomplete data. This could lead to sources being invisible in the UI or missing from operations.Additionally,
get_destinationsandget_webbackend_connectionshave TODO comments indicating these should be moved to paginated APIs, but this function doesn't. Consider adding a similar TODO comment for consistency, or implement proper pagination that fetches all pages.If immediate pagination implementation isn't feasible, at minimum:
For a complete fix, implement pagination:
def get_sources(workspace_id: str) -> List[Dict]: """Fetch all sources in an airbyte workspace""" if not isinstance(workspace_id, str): raise HttpError(400, "Invalid workspace ID") + all_sources = [] + page_size = 100 + offset = 0 + + while True: - res = abreq( - "sources/list", {"workspaceId": workspace_id, "pageSize": 100, "sortKey": "actorName_asc"} - ) + res = abreq( + "sources/list", + { + "workspaceId": workspace_id, + "pageSize": page_size, + "sortKey": "actorName_asc", + "offset": offset + } + ) - if "sources" not in res: - logger.error("Sources not found for workspace: %s", workspace_id) - raise HttpError(404, "sources not found for workspace") - return res + if "sources" not in res: + logger.error("Sources not found for workspace: %s", workspace_id) + raise HttpError(404, "sources not found for workspace") + + all_sources.extend(res["sources"]) + + # Break if we got fewer items than page size (last page) + if len(res["sources"]) < page_size: + break + + offset += page_size + + return {"sources": all_sources}Note: Verify if the Airbyte API uses
offsetor a different pagination mechanism (e.g.,pageToken).📝 Committable suggestion
🤖 Prompt for AI Agents