Skip to content

fix: kling correct fail reason#2532

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr/620211e02bd55545f0fa4568f3d55c3b4d7f3305
Jan 3, 2026
Merged

fix: kling correct fail reason#2532
seefs001 merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr/620211e02bd55545f0fa4568f3d55c3b4d7f3305

Conversation

@feitianbubu
Copy link
Copy Markdown
Contributor

@feitianbubu feitianbubu commented Dec 26, 2025

可灵的错误返回, message永远是SUCCESS
TaskStatusMsg才是正确的错误信息
{"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

  • Bug Fixes
    • Improved task status message extraction to correctly source information from the appropriate nested data payload, ensuring more accurate status details are displayed.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 26, 2025

Walkthrough

Modified response parsing in the Kling adaptor to extract the task status reason from resPayload.Data.TaskStatusMsg instead of the top-level resPayload.Message field, aligning with the nested data structure.

Changes

Cohort / File(s) Summary
Response parsing update
relay/channel/task/kling/adaptor.go
Changed taskInfo.Reason population source from resPayload.Message to resPayload.Data.TaskStatusMsg to use the nested task status message

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Hop, hop, the message did move,
From top to the depths of the groove,
Task status shines bright,
In the right place at night,
One change and our reason's in proof!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: kling correct fail reason' directly describes the main change: correcting how the failure reason is extracted from the Kling service response.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-level Message. However, based on the PR fix, when tasks fail during processing (not submission), Code is 0 but task_status is "failed" with the error in task_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 TaskStatusMsg when 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9aeef6a and 37a1882.

📒 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 message field even when tasks fail, with the actual error detail located in task_status_msg. Extracting the reason from resPayload.Data.TaskStatusMsg ensures accurate failure messages are captured during task status polling.

@seefs001 seefs001 merged commit 3510b3e into QuantumNous:main Jan 3, 2026
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
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.

2 participants