Repository navigation
fix(download): send User-Agent on outbound HTTP - ModelScope CDN 403 on every model download - #245
Merged
Merged
Conversation
…on every download Every ModelScope model download failed with "403 Forbidden" while the browser downloaded the same file fine. Root cause is not the network: reqwest sends NO User-Agent header by default, and the object-store CDN that ModelScope 302s to (cdn-lfs-cn-1.modelscope.cn, Aliyun WAF, acw_tc cookie) rejects UA-less stream requests with 403. ModelScope's JSON APIs do not check the UA, so market search and file listing worked and only the actual byte transfer died. Measured with the same URL and Range on this machine: - bare reqwest::Client (no UA) -> 403 Forbidden - via the new client (AIO-Desktop/1.0.0-alpha.6) -> 206 Partial Content, Content-Range: bytes 0-1023/8988111168 Changes: - core/http.rs: single outbound identity (user_agent() = AIO-Desktop/<version>, client_builder() preloaded with it); module doc records the trap - wire it into the three previously bare clients: local GGUF downloader, market metadata client (HF mirror / ModelScope lists), embedding+rerank manifest downloader - failure reporting: keep one reason per source instead of only the last one, give 403 its own actionable bilingual message, and say "no usable source" when the request carries neither hfRepo nor msRepo (was an empty reason) - tests: core::http +2 (UA content; a local minimal HTTP server proves the client really sends it - no network), local_model_download +1 (failure aggregation keeps each source once) Verification: npm run verify green (i18n 1195 keys, docs 37 files, gates rgba=173/any=77 held, prettier/eslint/tsc clean, 93 FE tests, vite build; cargo fmt + clippy -D warnings + 473 Rust tests passed / 0 failed).
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.
问题
本地模型下载页对 ModelScope 模型全部失败:
下载失败:下载 DeepCoder-14B-Preview-Q4_K_M.gguf 失败(已尝试所有来源): HTTP 403 Forbidden同一台机器网络正常,浏览器从 modelscope.cn 网页下载同一文件毫无问题。
根因
不是网络,是请求缺 User-Agent:
cdn-lfs-cn-1.modelscope.cn;acw_tccookie)对缺失 UA 的取流请求直接 403;reqwest默认不发 User-Agent(curl、浏览器都发——所以网页下载正常);/api/v1/dolphin/models、/repo/files)不校验 UA,所以市场能搜到、能列文件,只有真正取文件那一跳全灭——现象因此非常像"网络/权限"问题。实测对证(同一 URL、同一 Range,本机)
reqwest::Client(无 UA,即修复前行为)403 ForbiddenAIO-Desktop/1.0.0-alpha.6)206 Partial Content,Content-Range: bytes 0-1023/8988111168改动
core/http.rs:统一出站身份user_agent()=AIO-Desktop/<包版本>+client_builder()起手式;模块头注释记录这个坑与「新增出站客户端必须带 UA」的约定core/http.rs;CHANGELOG 记入## [Unreleased]测试
core::http+2:UA 自报产品名与版本;client_builder起手的客户端确实发出 UA(本地最小 HTTP 服务器抓请求头,不外网)local_model_download+1:失败原因按来源保留、相邻重复合并npm run verify全绿:i18n 1195 键、docs 37 文件、gates rgba=173/any=77 持平、prettier/eslint/tsc 干净、93 FE 测试、vite build;cargo fmt + clippy-D warnings+ 473 Rust 测试通过 / 0 失败行为影响
Fixes 用户实装反馈(本地模型下载 403)