Skip to content

fix: use Jimeng request key for task polling - #5294

Draft
yzhkali wants to merge 1 commit into
QuantumNous:mainfrom
yzhkali:fix/jimeng-fetch-req-key-5278
Draft

fix: use Jimeng request key for task polling#5294
yzhkali wants to merge 1 commit into
QuantumNous:mainfrom
yzhkali:fix/jimeng-fetch-req-key-5278

Conversation

@yzhkali

@yzhkali yzhkali commented Jun 3, 2026

Copy link
Copy Markdown

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

Jimeng can transform the submitted request key before sending a task, especially for v30 image and first/last-frame modes. Polling previously did not retain that transformed key, so result queries could use a different provider key.

This change stores the actual request key used for submission in upstream_request_key and reuses it for asynchronous polling. Tasks created before that field existed keep the previous fixed polling key. Their original image count and transformed request key were not persisted, so deriving a replacement from model/action fields is not reliable.

The external API and task response format are unchanged.

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)
  • ✨ 新功能 (New feature)
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 Issues 与 PRs,确认不是重复提交。
  • Bug fix 说明: 此 PR 已关联对应 Issue,且不是设计取舍或预期不一致。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

Run on commit 957e37d1 with GOMAXPROCS=4 and build caches under /www/codex-work/tmp/oss-build:

go test ./relay/channel/task/jimeng -count=1
ok github.com/QuantumNous/new-api/relay/channel/task/jimeng

go test ./service -count=1
ok github.com/QuantumNous/new-api/service

go test ./model -run 'Task|InitTask' -count=1
ok github.com/QuantumNous/new-api/model

git diff --check
(no output)

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The change persists provider-specific request keys in task properties, resolves Jimeng request keys from request context, and includes upstream task and model metadata in polling requests.

Changes

Upstream request key persistence and resolution

Layer / File(s) Summary
Task metadata and persistence
model/task.go, relay/common/relay_info.go, model/task_cas_test.go
TaskRelayInfo and task Properties now store UpstreamRequestKey. InitTask persists the key and tests verify the stored metadata.
Jimeng request-key resolution
relay/channel/task/jimeng/adaptor.go
Jimeng request keys are resolved from model, image, action, and metadata context. Resolved keys are stored and reused for task fetching.
Polling payload construction
service/task_polling.go, service/task_polling_test.go
BuildTaskFetchBody includes task, model, and request-key context. updateVideoSingleTask uses the new payload builder.
Jimeng adaptor validation
relay/channel/task/jimeng/adaptor_test.go
Tests cover model variants, payload propagation, persisted keys, fallback resolution, signed requests, missing task IDs, and custom metadata keys.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant JimengAdaptor
  participant TaskStore
  participant PollingService
  Client->>JimengAdaptor: Submit task with model and image context
  JimengAdaptor->>JimengAdaptor: Resolve upstream request key
  JimengAdaptor->>TaskStore: Persist task and UpstreamRequestKey
  PollingService->>TaskStore: Load task properties
  PollingService->>JimengAdaptor: Fetch task with task and request-key context
  JimengAdaptor-->>PollingService: Return upstream task status
Loading

Possibly related PRs

Suggested reviewers: calcium-ion

Poem

A rabbit stores the request key,
Jimeng uses the model it sees.
Polling carries the saved detail,
Fetch requests follow the right trail.
The task returns with context clear.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR stores and reuses the actual Jimeng request key during polling, addressing the hardcoded-key failure in [#5278].
Out of Scope Changes check ✅ Passed All production changes and tests support request-key persistence and Jimeng task polling; no unrelated scope is evident.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: using the Jimeng request key during task polling.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@yzhkali

yzhkali commented Jun 17, 2026

Copy link
Copy Markdown
Author

Following up in case this fell through. This PR is focused on #5278: Jimeng task polling now uses the request key returned by task creation, with coverage for the polling path.

Checks are green. Happy to adjust the key-selection behavior if you prefer a different source of truth.

@yzhkali
yzhkali force-pushed the fix/jimeng-fetch-req-key-5278 branch 2 times, most recently from 9ec62e4 to 80e90f6 Compare August 8, 2026 15:15
@yzhkali
yzhkali marked this pull request as draft August 8, 2026 15:17
@yzhkali
yzhkali force-pushed the fix/jimeng-fetch-req-key-5278 branch from 80e90f6 to 957e37d Compare August 8, 2026 15:21
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.

即梦模型被写死了

1 participant