Skip to content

fix(BA-4879): Update vfolder client to match new REST API response format#9663

Open
hhoikoo wants to merge 2 commits intomainfrom
fix/BA-4879
Open

fix(BA-4879): Update vfolder client to match new REST API response format#9663
hhoikoo wants to merge 2 commits intomainfrom
fix/BA-4879

Conversation

@hhoikoo
Copy link
Member

@hhoikoo hhoikoo commented Mar 5, 2026

resolves #9662 (BA-4879)

Update the vfolder client SDK (client/func/vfolder.py) and CLI (client/cli/vfolder.py) to match the updated server REST API response format, and fix the resulting mypy type errors and unit test mocks.

The server now wraps single-item responses in {"item": {...}}. This PR unwraps that envelope in create(), info(), and clone() so callers receive the inner dict directly. Each unwrap site uses an explicit intermediate variable (item: dict[str, Any] = result["item"]) to satisfy mypy's no-any-return check. Additionally, _get_id_by_name() now sends the folder name as a query parameter (vfolder_name=) instead of a JSON body and reads the id from data["item"]["id"].

Field renames in CLI output are also applied to match the new API contract:

  • numFiles -> num_files in vfolder info
  • inviter_user_email -> inviter in vfolder invitations

Unit tests in tests/unit/client/test_vfolder.py and tests/unit/client/test_vfolder_tus.py are updated to reflect these changes: mock payloads are wrapped in {"item": ...}, and _get_id_by_name mocks use query-parameter URLs. The build_url helper in the TUS test module gains an optional params argument to support URL-encoded query parameters.

Checklist: (if applicable)

  • Milestone metadata specifying the target backport version
  • Mention to the original issue
  • Installer updates including:
    • Fixtures for db schema changes
    • New mandatory config options
  • Update of end-to-end CLI integration tests in ai.backend.test
  • API server-client counterparts (e.g., manager API -> client SDK)
  • Test case(s) to:
    • Demonstrate the difference of before/after
    • Demonstrate the flow of abstract/conceptual models with a concrete implementation
  • Documentation
    • Contents in the docs directory
    • docstrings in public interfaces and type annotations

…rmat

Server responses are now wrapped in {"item": {...}} instead of returning
data at the top level. Also fixes field renames (numFiles -> num_files,
inviter_user_email -> inviter) and the _get_id_by_name() endpoint which
now accepts the folder name as a query param instead of a JSON body.
Copilot AI review requested due to automatic review settings March 5, 2026 06:05
@hhoikoo hhoikoo self-assigned this Mar 5, 2026
@github-actions github-actions bot added size:S 10~30 LoC comp:client Related to Client component comp:cli Related to CLI component labels Mar 5, 2026
@hhoikoo hhoikoo added the skip:changelog Make the action workflow to skip towncrier check label Mar 5, 2026
@hhoikoo hhoikoo requested a review from a team March 5, 2026 06:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the legacy vfolder client SDK and CLI output handling to align with the manager REST API’s updated response/field formats (notably the new single-item {"item": ...} envelope).

Changes:

  • Unwrap {"item": ...} for vfolder create(), info(), clone(), and ID lookup (_get_id_by_name() reads data["item"]["id"]).
  • Change vfolder ID lookup to pass the folder name via query param (vfolder_name=) instead of a JSON body.
  • Update CLI output field names (numFilesnum_files, inviter_user_emailinviter).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
src/ai/backend/client/func/vfolder.py Unwraps the new item envelope for several endpoints and updates ID lookup request/response parsing.
src/ai/backend/client/cli/vfolder.py Adjusts displayed field names in vfolder info and vfolder invitations to match the new API contract.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…sponse format

- Add explicit type annotation for `result["item"]` to fix mypy no-any-return errors
- Update test mock payloads to wrap responses in `{"item": ...}` wrapper
- Update test mock URLs for `_get_id_by_name` to use query params instead of JSON body
@github-actions github-actions bot added size:L 100~500 LoC and removed size:S 10~30 LoC labels Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:cli Related to CLI component comp:client Related to Client component size:L 100~500 LoC skip:changelog Make the action workflow to skip towncrier check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broken vfolder CLI commands

2 participants