Repository navigation
fix(distributor): resolve model for GET /v1/video/generations/:task_id - #5133
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughBackfills modelRequest.Model for relay-mode GET fetch-by-ID video endpoints by loading the persisted task and using its Properties.OriginModelName so downstream token model-access validation uses the original model name. ChangesVideo Task Status Model Backfill
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
When a token has "available models" restriction enabled, polling a video task status via GET /v1/video/generations/:task_id failed with: This token has no access to model Because the GET branch in getModelRequest() set shouldSelectChannel=false but never populated modelRequest.Model. The later modelLimitEnable check then ran against an empty model name and rejected the request, even though the same token was perfectly allowed to submit the task in the first place. The original (POST) request was already persisted in the task table via Properties.OriginModelName. This change looks it up by (user_id, task_id) and back-fills modelRequest.Model so the model-limit check runs against the correct model — matching the behavior of the POST submit path. Fixes QuantumNous#4834 Co-authored-by: Cursor <[email protected]>
f74964f to
385bb50
Compare
panjinhe
left a comment
There was a problem hiding this comment.
Reviewed by Codex: small focused fix, checks passing.
|
Please disregard my previous approval on this PR. It was submitted by mistake while I was checking the wrong repository. |
… id 等) 主要变更(QuantumNous/new-api → adc390c): - feat: 渠道被禁用后可配置是否清空渠道粘性 (QuantumNous#5306) - feat(web): profile 页显示 user id (QuantumNous#5317) - fix: 复用 channel handler 的 stream scanner buffer (QuantumNous#5225) - fix: 收窄 OpenAI o 系列模型适配范围 (QuantumNous#5293) - fix(relay): GLM Anthropic 兼容避免 chunked encoding (QuantumNous#5307) - fix: 新增 relay idle 连接超时配置 (QuantumNous#5309) - fix: 限制匿名请求体大小 (QuantumNous#5244) - fix(distributor): 修复 video generations task_id 模型解析 (QuantumNous#5133) - fix(dify): 远程图片字段赋值前初始化 file pointer (QuantumNous#5134) - fix(i18n): 优化 thinking adapter 文案 (QuantumNous#5242) 去合规一致性:上游未触及任何合规文件,合并完整保留本地去合规状态 (payment_setting.go / payment-settings-section.tsx / recharge-form-card.tsx / risk-acknowledgement-dialog.tsx 均未被改动)。 i18n:web/default 6 语言(en/zh/fr/ja/ru/vi)key 并集三路合并 + i18n:sync 规范化,4584 keys/语言,missing/extras/untranslated 全为 0。 验证:go build ./... ✅ + bun run typecheck ✅
合并上游 QuantumNous/new-api v1.0.0-rc.11,主要新增 Claude Opus 4.8、 OpenAI 图片流式中继、渠道粘性清空选项、安全审计日志、模型定价双栏重构、 Dialog prop-based API 重构。 冲突解决(20 文件): - 13 个 dialog 采用上游新结构,保留 dev sm: 响应式前缀与 ESLint 注释 - common-logs-columns / details-dialog 的 multikey 徽章功能完整保留 - channels-table 采用上游 useDebouncedColumnFilter - model-pricing-sheet / model-ratio-visual-editor 采用 upstream 版本 - codex-oauth-dialog 删除(跟随上游 QuantumNous#5461) 撞车修复核对通过:视频任务 GET 验证(QuantumNous#4834/QuantumNous#5133)、匿名请求体限制(QuantumNous#5244) 逻辑均正确保留,无重复。 验证:前端 typecheck + 生产 build 通过,后端 go build 通过,i18n 全语言对齐。
The plugin existed to put a RiverMoon relay's media models into Codex, but it only ever did images, and the tokens it provisioned were hardcoded to model_limits "gpt-image-2" — so a video model would have been refused even after a successful login. Capabilities now come from a channel list built in config. Each channel becomes one model-limited token on the user's account, and grants carry the resulting keys as a map instead of two named fields, so the next capability is a configuration change rather than another field threaded through OAuth. Grants issued before the map still resolve. Video generation is asynchronous, so generate_video submits the job, waits up to VIDEO_INLINE_WAIT_MS, and then hands back a task_id for check_video to poll. Both the tool description and the skill are explicit that a running task must never be resubmitted, since every submission is billed. A finished clip is returned as a URL; an mp4 is far past any inline limit. Video stays hidden until VIDEO_MODELS names a model the relay exposes, so a relay without video channels advertises no video tools. Task queries need NewAPI with QuantumNous/new-api#5133; older releases refuse a query made with a model-limited token, and that response is now reported as what it is. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FJveNjnJgo6jG53QfkUuGN
QuantumNous#5133) (cherry picked from commit 87cc22d)
📝 变更描述 / Description
修复 GET
/v1/video/generations/:task_id在 token 启用「可用模型限制」时被误判为This token has no access to model的问题。根因:
middleware/distributor.go的getModelRequest()在 GET 分支只设置了shouldSelectChannel = false,却没有把modelRequest.Model填上。后续Distribute()里的modelLimitEnable校验会拿空字符串去匹配 token 的可用模型列表,必然失败。由于任务提交(POST)时
task.Properties.OriginModelName已经持久化到数据库,本 PR 只是在 GET 分支里多加一次model.GetByTaskId(userId, taskId)查询,回填modelRequest.Model,让校验跑在正确的模型上 —— 与 POST 路径行为对齐。🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
#4834在 Issues/PRs 中无其它在修的 PR。/v1/video/generations/:task_id的 model 解析,不影响 POST 路径与其它端点;DB 查询用(user_id, task_id)复合条件,不会泄漏跨用户任务。go vet ./middleware/✅,go build ./middleware/✅,gofmt -l干净,已有middleware包测试无回归。GetByTaskId已经按 user_id 隔离。📸 运行证明 / Proof of Work
Bug 现场(来自 #4834)
修复前:
注意
model后面是两个空格 —— 因为 model 名称是空字符串拼进了错误消息里,这是肉眼可见的「model 没解析出来」。修复点
middleware/distributor.goGET 分支新增:边界行为
GetByTaskId按user_id过滤返回不存在,行为不变(既存安全语义保留)本地验证
完整 build 需要前端
web/classic/dist,超出此 PR 范围。备注
middleware/distributor.go当前没有单元测试,GetByTaskId依赖真实 DB,所以本 PR 未追加单测;如维护者希望补,我可以另外引入 sqlmock 在下一 PR 里加。Made with Cursor
Summary by CodeRabbit