fix: kling correct fail reason#2532
Conversation
WalkthroughModified response parsing in the Kling adaptor to extract the task status reason from Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 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 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
relay/channel/task/kling/adaptor.go (1)
398-403: Consider handling task processing failures consistently.The error population logic only triggers when
klingResp.Code != 0, using the top-levelMessage. However, based on the PR fix, when tasks fail during processing (not submission),Codeis 0 buttask_statusis "failed" with the error intask_status_msg. This means failed tasks (code=0, status="failed") won't have their error messages populated here.Consider adding logic to populate the error message from
TaskStatusMsgwhen the task status indicates failure, similar to the fix at line 349.🔎 Suggested enhancement for consistency
if klingResp.Code != 0 && klingResp.Message != "" { openAIVideo.Error = &dto.OpenAIVideoError{ Message: klingResp.Message, Code: fmt.Sprintf("%d", klingResp.Code), } + } else if klingResp.Data.TaskStatus == "failed" && klingResp.Data.TaskStatusMsg != "" { + openAIVideo.Error = &dto.OpenAIVideoError{ + Message: klingResp.Data.TaskStatusMsg, + Code: "task_failed", + } }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
relay/channel/task/kling/adaptor.go
🔇 Additional comments (1)
relay/channel/task/kling/adaptor.go (1)
349-349: LGTM! Correctly extracts failure reason from nested field.This change properly addresses the issue where the external service returns "SUCCESS"/"SUCCEED" in the top-level
messagefield even when tasks fail, with the actual error detail located intask_status_msg. Extracting the reason fromresPayload.Data.TaskStatusMsgensures accurate failure messages are captured during task status polling.
…545f0fa4568f3d55c3b4d7f3305
可灵的错误返回, message永远是
SUCCESSTaskStatusMsg才是正确的错误信息
{"code": 0, "data": {"task_id": "833446756*******", "task_info": {}, "created_at": 1766737710125, "updated_at": 1766737711775, "task_result": {}, "task_status": "failed", "task_status_msg": "Image pixel is invalid"}, "message": "SUCCEED", "request_id": "ace7625a-3e18-49aa-abc4-*******"}Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.