[bug] Local media upload is pinned to China endpoint; Singapore workspace API key fails getPolicy (401 InvalidApiKey)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 54/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
Hướng nghiên cứu
Start with packages/core/src/files/upload.ts and trace how the active profile’s base_url or region reaches resolveFileUrl, uploadFile, and getUploadPolicy. Confirm which regions support the temporary upload policy, then add the proposed host selection and unsupported-region handling with tests for China, Singapore, and an unsupported region. Done means local uploads use a supported regional endpoint or explain how to use an HTTPS reference; the issue names no test file.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Local reference files cannot be uploaded from an international Singapore (ap-southeast-1) Model Studio workspace using bl video ref. The local-file upload path requests an OSS upload policy from the China DashScope endpoint regardless of the active profile's base_url, and that request fails with HTTP 401 InvalidApiKey.
This fails before the video-generation task is submitted. Passing an already-hosted HTTPS reference is a practical workaround because that bypasses local auto-upload.
Environment
- Bailian CLI:
2.3.2 - OS: macOS on Apple Silicon (arm64)
- Active config:
default - Console site:
international - Region:
ap-southeast-1(Singapore) - API key: configured, redacted (workspace-specific key)
base_url:https://ws-<workspace-id>.ap-southeast-1.maas.aliyuncs.com(workspace ID redacted)- Model:
wan3.0-video
Sanitized output of bl auth status --output json:
{
"authenticated": true,
"config": "default",
"api_key": {
"source": "config",
"masked": "<REDACTED>",
"base_url": "https://ws-<workspace-id>.ap-southeast-1.maas.aliyuncs.com"
},
"console": {
"source": "config",
"masked": "<REDACTED>",
"region": "ap-southeast-1",
"site": "international"
}
}
Note: The authenticated: true status indicates that credentials are configured; this alone is not a live validity check.
Steps to reproduce
- Configure a Model Studio API key and workspace endpoint for
ap-southeast-1. - Confirm the active profile with
bl auth status --output json. - Place an existing short MP4 in the current directory (for example,
sample.mp4). - Run the supported local-reference workflow:
bl video ref \
--model wan3.0-video \
--ref-video ./sample.mp4 \
--prompt "Video 1 continues moving" \
--duration 5 \
--resolution 720P \
--ratio 9:16
The original failure was observed through a small wrapper that delegates reference-video generation to bl, using a 4.97-second MP4 reference and requesting 5 seconds of output at 480P. The error occurs while obtaining the upload policy, before the requested generation resolution is validated or the model task is submitted. The command above uses the CLI-documented 720P to isolate the upload problem.
Actual behavior
Failed to get upload policy (HTTP 401):
{"code":"InvalidApiKey","message":"Invalid API-key provided.","request_id":"3e6e555d-dcd5-9fd6-a05e-502c5a0e48eb"}
No task is submitted.
Root-cause evidence
The current implementation hardcodes the CN API host:
https://github.com/modelstudioai/cli/blob/main/packages/core/src/files/upload.ts
// Pinned to cn region; thread baseUrl through if overseas upload becomes a requirement.
const UPLOAD_API = `${REGIONS.cn}/api/v1/uploads`;
getUploadPolicy() builds its request from this constant. uploadFile() and resolveFileUrl() accept the API key and model, but do not propagate the active profile's base_url or region to the upload-policy request.
As a result, the Singapore workspace key is sent to a different regional endpoint than the configured model API. The mismatch is a strong explanation for this 401. The exact availability of the temporary upload-policy API in Singapore should be confirmed independently; a region-aware implementation should not assume all regions expose the same upload endpoint.
Expected behavior
- The uploader must respect the active profile/region when the corresponding upload service is supported.
- If local-file temporary uploads are unavailable in a given region, fail early with a precise explanation and guidance to use a reachable HTTPS media URL, rather than presenting the response as a generic invalid API key.
bl video ref --ref-video <local-file>should not silently use a China-only upload endpoint for an international profile.- The error message should include the effective upload region/host (without exposing credentials).
Suggested fix
- Thread the effective
base_url/ region context from the client throughresolveFileUrl,uploadFile, andgetUploadPolicy. - Resolve the upload-policy endpoint by supported region; distinguish an unsupported upload API from an invalid credential.
- Add unit tests asserting which host receives
getPolicyfor CN and international profiles, plus a negative test for an unsupported region. - Document HTTPS-reference input as an alternative when automatic local upload is not supported.
Workaround
Host the MP4 on an HTTPS endpoint reachable by Model Studio (for example, a temporary signed Cloudflare R2 GET URL) and pass that HTTPS URL to --ref-video instead of the local path. resolveFileUrl() leaves HTTPS inputs unchanged and skips the upload-policy request.
Related issues
- #171 — upload-policy 401 with a China token-plan profile (different credential/region combination).
- #264 — API key/profile precedence mismatch on other requests (may be related, but does not address the hardcoded uploader host).
This report concerns Singapore workspace-key local uploads specifically, not a token-plan key or generic auth-profile selection problem.
- Ngôn ngữ chính
- TypeScript
- Star
- 364
- Fork
- 32
- Merge trung bình
- 23 giờ 34 phút
- Pull request đã merge (30 ngày)
- 30
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelstudioai/cli
-
bug
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 62/100
modelstudioai/cli#279 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 48/100
modelstudioai/cli#264 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
modelstudioai/cli#202 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
modelstudioai/cli#195 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
modelstudioai/cli#190 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelstudioai/cli
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
awslabs/visual-asset-management-system#804 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
restatedev/sdk-typescript#813 ·
-
bug desktop P1 session XS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Merit-Systems/x402scan#1312 ·
-
type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Azure/apiops-cli#331 ·
Maintainer thường phản hồi trong vòng 3 ngày