Skip to content

fix: sf images list and sf images upload 400 errors by passing workspace param#260

Open
sigmachirality wants to merge 2 commits intomainfrom
cursor/fix-images-workspace-param-38f3
Open

fix: sf images list and sf images upload 400 errors by passing workspace param#260
sigmachirality wants to merge 2 commits intomainfrom
cursor/fix-images-workspace-param-38f3

Conversation

@sigmachirality
Copy link
Copy Markdown
Member

@sigmachirality sigmachirality commented Apr 9, 2026

Problem

sf images list returns a 400 error because the v2 API requires a workspace query parameter on GET /v2/images and a workspace field in the request body for POST /v2/images. The CLI was sending neither.

Changes

src/schema.ts

  • Added workspace?: string query param to the list_images_v2 operation
  • Added workspace?: string field to the vmorch_StartUploadRequest schema
  • This keeps the openapi-fetch client properly typed — no as any casts needed

New file: src/lib/images/utils.ts

  • Adds getDefaultWorkspace() which resolves the account ID from config (or fetches it via GET /v0/me and caches it) and returns the workspace URN sfc:workspace:{account_id}:default
  • Follows the same utils.ts pattern used in other src/lib/ feature directories

src/lib/images/list.ts

  • Passes workspace as a query param to GET /v2/images

src/lib/images/upload.ts

  • Includes workspace in the POST /v2/images request body alongside name

Verification

  • Typechecks clean (tsc --noEmit)
  • All existing tests pass
  • Lint clean (no new warnings/errors)

Slack Thread

Open in Web Open in Cursor 

The v2 API requires a workspace query param on GET /v2/images and a
workspace field in the body for POST /v2/images. The CLI was sending
neither, causing 400 errors.

- Add src/lib/images/utils.ts with getDefaultWorkspace() that resolves
  the account ID (from config or /v0/me) and returns the workspace URN
  sfc:workspace:{account_id}:default
- Update list.ts to pass workspace as a query param
- Update upload.ts to include workspace in the POST body

Co-authored-by: Daniel Tao <danieltaox@gmail.com>
@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com bot commented Apr 9, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  src/lib/images/list.ts  47% smaller
  src/lib/images/upload.ts  0% smaller
  src/lib/images/utils.ts  0% smaller
  src/schema.ts  0% smaller

Update schema.ts to include the workspace query param on list_images_v2
and the workspace field on vmorch_StartUploadRequest, so the openapi-fetch
client is properly typed. This removes the need for the 'as any' cast in
list.ts.

Co-authored-by: Daniel Tao <danieltaox@gmail.com>
@sigmachirality sigmachirality marked this pull request as ready for review April 9, 2026 20:58
@sigmachirality sigmachirality changed the title Fix sf images list and sf images upload 400 errors by passing workspace param fix: sf images list and sf images upload 400 errors by passing workspace param Apr 9, 2026
@sigmachirality sigmachirality self-assigned this Apr 9, 2026
Copy link
Copy Markdown
Contributor

@joshi4 joshi4 left a comment

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants