feat: enhance API responses with pagination support and model updates#152
feat: enhance API responses with pagination support and model updates#152Joffref wants to merge 1 commit into
Conversation
- Updated the API methods for listing agents, sandboxes, drives, functions, jobs, and job executions to support cursor-based pagination. - Refactored response parsing to return structured lists (e.g., AgentList, SandboxList, DriveList, FunctionList, JobList, JobExecutionList) instead of raw arrays. - Added new parameters for cursor, limit, sort, and anchor to improve query flexibility and response handling. - Updated documentation to reflect changes in response structure and pagination capabilities. This change improves the API's usability and aligns with the latest versioning standards.
There was a problem hiding this comment.
Needs attention — 1 issue in 1 file
AgentList.from_dict (and all sibling *List.from_dict methods) returns None when src_dict is falsy. A 200 response with an empty JSON object {} silently produces None from _parse_response, making it indistinguishable from a non-200 error path. More critically, the docstring explicitly states older API versions return a bare array — passing that array (even a non-empty one like [{...}]) to from_dict causes AttributeError on d.pop("data", UNSET) since lists don't support dict-style .pop. The pagination logic itself is correct; the model guard is the problem.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<assessment>
`AgentList.from_dict` (and all sibling `*List.from_dict` methods) returns `None` when `src_dict` is falsy. A 200 response with an empty JSON object `{}` silently produces `None` from `_parse_response`, making it indistinguishable from a non-200 error path. More critically, the docstring explicitly states older API versions return a bare array — passing that array (even a non-empty one like `[{...}]`) to `from_dict` causes `AttributeError` on `d.pop("data", UNSET)` since lists don't support dict-style `.pop`. The pagination logic itself is correct; the model guard is the problem.
</assessment>
<file name="src/blaxel/core/client/models/agent_list.py">
<issue location="src/blaxel/core/client/models/agent_list.py:63">
`from_dict` returns `None` for any falsy input, including an empty dict `{}` or a bare array from pre-2026-04-28 API versions. A 200 response with an empty body silently becomes `None`, and a bare-array response (which the docstring says older servers return) triggers an `AttributeError` on `d.pop()` for non-empty arrays.
</issue>
</file>
Tag @mendral-app with feedback or questions. View session
| if not src_dict: | ||
| return None | ||
| d = src_dict.copy() |
There was a problem hiding this comment.
bug (P1): from_dict returns None for any falsy input, including an empty dict {} or a bare array from pre-2026-04-28 API versions. A 200 response with an empty body silently becomes None, and a bare-array response (which the docstring says older servers return) triggers an AttributeError on d.pop() for non-empty arrays.
Suggested change
| if not src_dict: | |
| return None | |
| d = src_dict.copy() | |
| if src_dict is None: | |
| return None | |
| if not isinstance(src_dict, dict): | |
| raise ValueError(f"Expected a dict, got {type(src_dict).__name__}") | |
| d = src_dict.copy() |
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/blaxel/core/client/models/agent_list.py, line 63:
<issue>
`from_dict` returns `None` for any falsy input, including an empty dict `{}` or a bare array from pre-2026-04-28 API versions. A 200 response with an empty body silently becomes `None`, and a bare-array response (which the docstring says older servers return) triggers an `AttributeError` on `d.pop()` for non-empty arrays.
</issue>
This change improves the API's usability and aligns with the latest versioning standards.
Note
Adds cursor-based pagination to all list endpoints (agents, sandboxes, drives, functions, jobs, job executions). Return types change from
list[T]to structuredTListobjects containingdataandmetafields. New query parameterscursor,limit,sort,q, andanchorare threaded through all four call variants (sync_detailed, sync, asyncio_detailed, asyncio). The code is auto-generated from an OpenAPI spec.Written by Mendral for commit 7ad944f.