阿里视频任务轮询不支持多密钥模式(multi-key)

Open Beginner friendly
#6,864 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
go
Domain
api, backend

Research direction

Start in service/task_polling.go around line 456 and compare the video polling key handling with GetNextEnabledKey() in model/channel.go around line 199. Reproduce with an Alibaba channel configured with two keys, then verify that video task polling no longer sends the newline-separated value in the Authorization header and reaches the generated result.

Written by the indexing model from the issue text.

Description

bug
部署来源

本仓库 Release / 官方镜像(自行部署)

您当前的 newapi 版本

v1.0.0-rc.24

提交确认
  • 非重复 issue: 我已搜索现有 Issues,确认目前没有类似 issue。
  • 提交前必读: 我已完整阅读上方“提交前必读”,并已查看文档 https://docs.newapi.ai/、项目 README 且向 AI 提问,确认这不是使用、配置或接入类问题。
  • 受支持版本: 我已提供准确的版本号、commit 或镜像标签(不是 latestunknown),并确认问题可在本仓库未修改的受支持版本中复现。
  • 非第三方服务: 我确认这不是第三方托管站、中转站、API 服务或未经本仓库原版验证的 fork 所独有的问题;第三方实例问题应联系其运营方。
  • 问题归属: 我已提供足以区分客户端、new-api 和上游的证据;转发问题已使用等价的脱敏请求对比直连上游与经过 new-api 的结果,确认错误由 new-api 引入或改变,而非仅原样转发上游报错。
  • 渠道与协议边界: 我确认问题不是由 Coding Plan、逆向渠道、第三方封装接口、Codex 反代接口,或 Codex API 自身特有行为导致;若问题最初出现于此类接口,我已在本仓库支持的标准 API 协议上复现。
  • 维护成本: 我理解项目维护者精力有限,不遵循模板要求的 issue 可能会被无视或直接关闭。
问题描述

实际现象: 提交视频生成任务后,状态始终为 NOT_START,每 15 秒轮询报错:
Failed to update video task: fetchTask failed for task xxx:
net/http: invalid header field value for "Authorization"
影响范围: 配置了多密钥模式(multi-key)的渠道,提交视频生成任务后无法轮询到结果,任务永远卡在 NOT_START 状态。

发生频率: 必现(100%)。只要渠道使用多密钥模式,每次视频任务轮询都会触发。

判断问题位于 new-api 的依据:

普通聊天/文生图请求正常,说明多密钥模式和上游接口本身没问题
聊天请求路径使用 GetNextEnabledKey()(model/channel.go:199)正确处理多 Key,而视频轮询路径直接使用 ch.Key 原始字符串(service/task_polling.go:456
从数据库查到的 ch.Key 字段包含换行符(多密钥以 \n 分隔),直接拼入 HTTP Authorization 头导致 Go 标准库报错
仅保留一个 Key 并去掉换行后,视频轮询恢复正常

复现步骤

1.创建一个阿里百炼渠道,添加 2 个有效 API Key,开启多密钥模式(multi-key)
2.提交视频生成任务,返回 task_id
3.任务状态永远为 NOT_START,后端日志持续报错
Failed to update video task: fetchTask failed for task xxx:
net/http: invalid header field value for "Authorization"

预期结果

视频可以生成

相关截图

No response

Dominant language
Go
Stars
48.5k
Forks
11.6k
Avg merge
1d 9h
Merged PRs (30d)
61

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from QuantumNous/new-api

All issues in QuantumNous/new-api

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.