Skip to content

chore: add the stores helper functions - #245

Merged
joeldierkes merged 1 commit into
nextfrom
next-update
Oct 1, 2025
Merged

joeldierkes merged 1 commit into
nextfrom
next-update

Conversation

@joeldierkes

@joeldierkes joeldierkes commented Oct 1, 2025 •

Copy link
Copy Markdown
Contributor

Note

Introduce sync/async helpers to upload/attach files to stores and poll until processing reaches a terminal status.

  • Stores Files API:
    • Sync helpers (FilesResource):
      • poll: repeatedly retrieves StoreFile until status is completed/failed/cancelled.
      • create_and_poll: attach existing file_id to store then poll.
      • upload: upload via client.files.create then attach to store.
      • upload_and_poll: upload, attach, and poll to completion.
    • Async helpers (AsyncFilesResource):
      • poll, create_and_poll, upload, upload_and_poll async equivalents using polling.poll_async.
  • Internal:
    • Import polling, functools, and FileTypes to support new helpers and file uploads.

Written by Cursor Bugbot for commit 153269e. This will update automatically on new commits. Configure here.

@joeldierkes
joeldierkes merged commit 523ca4b into next Oct 1, 2025
12 of 14 checks passed
The file object once it reaches a terminal state
"""
self.create(
store_identifier=store_identifier, file_id=file_id, metadata=metadata, experimental=experimental, **kwargs

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Metadata Parameter Type Mismatch

The new create_and_poll, upload, and upload_and_poll methods (and their async versions) define the metadata parameter using NotGiven. However, they pass this parameter to the underlying create method, which expects Omit. This type annotation inconsistency may lead to type checking errors or unexpected runtime behavior.

Additional Locations (4)

Fix in Cursor Fix in Web

fn=functools.partial(self.retrieve, file_id, store_identifier=store_identifier, **kwargs),
condition=lambda res: res.status == "completed" or res.status == "failed" or res.status == "cancelled",
interval_seconds=polling_interval_ms / 1000,
timeout_seconds=polling_timeout_ms / 1000 if polling_timeout_ms else None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Poll Parameters Misinterpret Zero Values

The poll_interval_ms and poll_timeout_ms parameters in the poll methods (sync and async) incorrectly treat explicit 0 values as falsy. This causes 0 to be overridden by the default 500ms interval or None (no timeout), preventing users from setting an immediate interval or timeout and potentially leading to unexpected infinite polling.

Additional Locations (1)

Fix in Cursor Fix in Web

*,
store_identifier: str,
file: FileTypes,
metadata: Optional[object] | NotGiven = not_given,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Sync/Async upload Methods Have Inconsistent Metadata Handling

The metadata parameter in the upload methods has an inconsistent type annotation and default value between the sync and async versions. One uses Optional[object] | Omit = omit while the other uses Optional[object] | NotGiven = not_given. This also creates a type mismatch when upload passes metadata to the create method, which expects object | Omit.

Fix in Cursor Fix in Web

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant