Skip to content

fix(files): use the active endpoint for temporary uploads - #271

Open
Uddoo wants to merge 2 commits into
modelstudioai:mainfrom
Uddoo:fix/267-regional-file-upload
Open

Uddoo wants to merge 2 commits into
modelstudioai:mainfrom
Uddoo:fix/267-regional-file-upload

Conversation

@Uddoo

@Uddoo Uddoo commented Oct 20, 2026 •

Copy link
Copy Markdown

Fixes #267. Local media uploads requested a temporary upload policy from the CN host even when
the active model credential belonged to another region or workspace.

Route policy requests through the effective model-service origin. The shared uploader uses
the resolved credential origin by default; Prime video generation also supplies the same lazy
Workspace default used for submission and polling. This covers local reference files and both
keyframe images while keeping explicitly configured origins ahead of the Workspace default.
A missing required Workspace is reported before uploading. Direct SDK callers that omit the
optional base URL retain the CN default.

Policy failures include the effective endpoint and retain the original service response;
there is no cross-region retry. Existing media URLs pass through without uploading. The
URL-maintenance guide documents routing and the HTTPS-reference workaround. No command flags,
credential-selection priorities, dependencies, package versions, or workflows change.

Verification

  • Initial regression on base 3638180f48b8fb1c7f99d5db91d3882d021710e5:
    6 failed, 5 passed; non-CN policy requests incorrectly reached CN.
  • Prime follow-up regression on ca1989e175dffb2926a78de44323432b1ca16ae7:
    4 failed, 8 passed; local files/keyframes reached CN and a missing Workspace was checked
    only after upload.
  • Current focused Prime/upload/image regressions: 35 passed.
  • Ubuntu 24.04, Node 22.23.3, pnpm 10.33.2, Bun 1.3.14, using the exact source
    committed in c0dfddec40cbe2327f40e0f866ee724cfdfb18bb:
    • pnpm run sync:skill-assets
    • pnpm -r --filter "./packages/*" build
    • pnpm run check — 0 errors; 4 warnings in unchanged files
    • pnpm test --maxWorkers 4 — 3157 passed, 245 skipped, 0 failed
  • Windows Node 24.16.0: current focused tests and pnpm check pass. The earlier full-suite run
    at ca1989e reported 3114 passed, 245 skipped, 34 failed; all 34 failing cases were
    individually reproduced on the unmodified base above. The Windows full suite was not rerun
    for the Prime follow-up, and no Windows full-suite pass is claimed.
  • All six PR files were verified byte-identical between the committed tree and the Linux test
    copy. Commit hooks ran normally without changing those sources; git diff --check passes.

The new tests cover regional credential-origin pairing, derived Prime Workspace uploads,
explicit-origin priority, both local keyframes, missing-Workspace preflight, OSS upload without
forwarding the API bearer token, the legacy SDK default, URL normalization, service errors
without fallback, and URL/Data-URI passthrough.

Limits

All new HTTP tests use synthetic credentials and stubbed responses. Live E2E gates were
explicitly disabled, and no model-generation or other paid service call was made. Actual
Singapore or Workspace temporary-upload service availability has not been validated with
a live key. The selected service remains authoritative about region/model support; its errors
are not reclassified as guessed credential or capability failures.

AI disclosure

Autonomous Codex performed the investigation, implementation, automated test runs, and
self-review on behalf of Uddoo. No human review or manual verification is claimed.

Pass the resolved credential origin through the shared client and uploader. Keep the direct SDK CN default, show the effective policy endpoint on failure, and preserve service errors without cross-region retries.

Fixes modelstudioai#267. AI disclosure: implemented, tested and self-reviewed by autonomous Codex on behalf of Uddoo. No human review or live provider validation is claimed.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T03:01:15.978219Z ca1989e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca1989e175

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/agents/url-change.md
/api/v1/uploads 直接 SDK 调用未提供 baseUrl 时保持 REGIONS.cn 默认值
```

临时文件上传与后续模型请求使用同一 API origin,包括国际区、Workspace 和自定义代理。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Account for Prime's derived workspace upload origin

When bl video generate --prime --workspace-id <id> --model wan3.0-video --file <local> uses a workspace-only key from --api-key or the environment and no base URL, credential.baseUrl still defaults to CN, so the upload at packages/commands/src/commands/video/generate.ts:228 occurs before line 235 derives the workspace submit URL. The policy request therefore still goes to CN while the model request would go to the workspace, making this new same-origin invariant false and leaving that supported workspace path broken; resolve and pass the Prime origin before uploading or qualify the guide.

AGENTS.md reference: AGENTS.md:L3-L3

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Autonomous Codex follow-up on behalf of Uddoo: fixed in c0dfdde.

Confirmed with a command-level regression: on ca1989e, 4 tests failed because local files and keyframes used CN, and a missing Workspace was checked only after uploading. The uploader now honors the same lazy service-default origin as Client.url; Prime video passes its existing Workspace resolver for local files and both keyframes. Explicitly configured origins still win without requiring a Workspace, and existing media URLs pass through.

The 35 focused regressions pass. On isolated Ubuntu 24.04 with Node 22.23.3, pnpm 10.33.2 and Bun 1.3.14, skill asset sync, all package builds, and pnpm check pass (4 warnings in unchanged files); the full suite reports 3157 passed, 245 skipped, 0 failed. All six committed PR files match the Linux test copy byte-for-byte. Commit hooks ran normally. Windows full-suite limitations remain documented in the updated PR description.

All HTTP responses were mocked with synthetic keys; no live Workspace/Singapore upload availability, paid provider call, human review, or manual verification is claimed. The review conversation remains for the reviewer to confirm.

Honor the existing lazy service-default origin when uploading local files
and keyframes for Prime video generation. Keep configured origins ahead
of the workspace default and validate missing workspace before upload.

Add command-level mocked HTTP regressions for workspace/default routing,
explicit origins, both keyframes, and existing media URL passthrough.

AI disclosure: autonomous Codex implemented, tested and self-reviewed this
follow-up on behalf of Uddoo. No human review or live provider validation
is claimed.

This branch has not been deployed

No deployments
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.

[bug] Local media upload is pinned to China endpoint; Singapore workspace API key fails getPolicy (401 InvalidApiKey)

1 participant