fix: accept fractional usage.duration in Ali video task results - #6174
Open
feitianbubu wants to merge 1 commit into
Open
fix: accept fractional usage.duration in Ali video task results#6174feitianbubu wants to merge 1 commit into
feitianbubu wants to merge 1 commit into
Conversation
Successful Ali video tasks can report fractional usage durations (e.g. "duration": 13.93). IntValue tried int then string, and Go refuses to decode a float literal into int, so the whole task result unmarshal failed: the succeeded video URL was never persisted, settlement never ran, and every polling round repeated the error. Parse as float64 and truncate, with a ParseFloat fallback for string forms.
Contributor
Walkthrough
ChangesNumeric IntValue parsing
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
11 tasks
JacksonsY
added a commit
to JacksonsY/new-api
that referenced
this pull request
Jul 19, 2026
移植上游 PR QuantumNous#6174。 阿里视频任务成功时 usage.duration 可能是小数(如 13.93),而 IntValue 先按 int 解码,Go 拒绝把浮点字面量解进 int,导致整个 task result 解析 失败:视频 URL 从未落库、结算从不执行、每轮轮询重复报错。改为按 float64 解析后截断,字符串形式回退 ParseFloat。 在上游方案上补饱和转换:改走 float64 后,超出 int 范围的上游数值 (如 1e300)转 int 是未定义行为,而原先的 int 解码会正确报错。IntValue 承载的正是上游用量数字(ali usage.duration、doubao duration),按 AGENTS.md 的计费安全不变量必须饱和而非回绕,并补溢出回归测试。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
JacksonsY
added a commit
to JacksonsY/new-api
that referenced
this pull request
Jul 19, 2026
移植上游 PR QuantumNous#4810。 - ModelList 补 wan2.7-r2v / wan2.7-videoedit 与 happyhorse 1.0/1.1 - 补齐新版请求字段:reference_video_urls、reference_voice、ratio、 audio_setting、shot_type,以及 usage 的 size/ratio/输入输出时长 - 新增 multipart.go:把 image_url / video_url / audio_url 表单字段按 模型映射进 input.media(r2v 与 videoedit 归 reference_image, videoedit 的视频归 video,其余归 reference_video) - 校验入口从 ValidateMultipartDirect 统一为 ValidateBasicTaskRequest, 后者同样执行 validateTaskDurationBounds 且原生支持 multipart, 时长上界校验不丢失 - EstimateBilling 保留 min(Duration, MaxTaskDurationSeconds) 钳制 上游 PR QuantumNous#4078(万相 wan2.7)未单独移植:仓库已含 wan2.7-i2v/t2v,其余 内容(四个 wan2.7 模型、ratio/audio_setting、usage 扩展、分辨率倍率) 均为本 PR 的子集;其 AliUsage.Duration 改 float64 的方案也已由 QuantumNous#6174 的 IntValue 饱和解码更完整地覆盖。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Calcium-Ion
force-pushed
the
main
branch
2 times, most recently
from
August 30, 2026 15:03
51fdfc5 to
2b6f1df
Compare
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.
阿里视频任务(如 happyhorse-1.0-video-edit)成功后,查询响应里的
usage.duration可能是浮点数(实测返回过13.93、20.02)。dto.IntValue之前只按 int → string 两步解析,无法解析小数。改为先按 float64 解析再截断取整,字符串分支同样换成 ParseFloat,int / 浮点 / 数字字符串三种形式都能解。这条路径的 usage 不参与计费(ParseTaskResult 只读状态和 URL),截断没有计费影响。附了表驱动测试。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work