fix: sf images list and sf images upload 400 errors by passing workspace param#260
Open
sigmachirality wants to merge 2 commits intomainfrom
Open
fix: sf images list and sf images upload 400 errors by passing workspace param#260sigmachirality wants to merge 2 commits intomainfrom
sf images list and sf images upload 400 errors by passing workspace param#260sigmachirality wants to merge 2 commits intomainfrom
Conversation
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>
Changed Files
|
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>
sf images list and sf images upload 400 errors by passing workspace paramsf images list and sf images upload 400 errors by passing workspace param
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
sf images listreturns a 400 error because the v2 API requires aworkspacequery parameter onGET /v2/imagesand aworkspacefield in the request body forPOST /v2/images. The CLI was sending neither.Changes
src/schema.tsworkspace?: stringquery param to thelist_images_v2operationworkspace?: stringfield to thevmorch_StartUploadRequestschemaas anycasts neededNew file:
src/lib/images/utils.tsgetDefaultWorkspace()which resolves the account ID from config (or fetches it viaGET /v0/meand caches it) and returns the workspace URNsfc:workspace:{account_id}:defaultutils.tspattern used in othersrc/lib/feature directoriessrc/lib/images/list.tsworkspaceas a query param toGET /v2/imagessrc/lib/images/upload.tsworkspacein thePOST /v2/imagesrequest body alongsidenameVerification
tsc --noEmit)Slack Thread