Conversation
WalkthroughThe Kling adaptor is enhanced to support new Kling v2.6+ features. A new WatermarkInfo struct is introduced alongside a Sound field in the request payload. The GetModelList method is updated to include additional Kling model variants (v2-1-master, v2-5-turbo, v2-6) beyond the existing ones. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
relay/channel/task/kling/adaptor.go (2)
5-5: 🛠️ Refactor suggestion | 🟠 MajorDirect
encoding/jsonimport violates coding guidelines.This file imports
encoding/jsonand usesjson.Marshal/json.Unmarshaldirectly in multiple places (lines 165, 189, 276, 280, 349, 383) instead of the required wrapper functions. Line 410 already correctly usescommon.Marshal. The new fields introduced in this PR (Sound,WatermarkInfo) are serialized through these non-compliant calls.Suggested fix
Replace all direct
json.Marshal/json.Unmarshalcalls withcommon.Marshal/common.Unmarshal, and remove theencoding/jsonimport (keeping only type references likejson.RawMessageif needed — though none appear used here).- "encoding/json"- data, err := json.Marshal(body) + data, err := common.Marshal(body)- err = json.Unmarshal(responseBody, &kResp) + err = common.Unmarshal(responseBody, &kResp)- medaBytes, err := json.Marshal(metadata) + medaBytes, err := common.Marshal(metadata)- err = json.Unmarshal(medaBytes, &r) + err = common.Unmarshal(medaBytes, &r)- err := json.Unmarshal(respBody, &resPayload) + err := common.Unmarshal(respBody, &resPayload)- if err := json.Unmarshal(originTask.Data, &klingResp); err != nil { + if err := common.Unmarshal(originTask.Data, &klingResp); err != nil {As per coding guidelines, "All JSON marshal/unmarshal operations MUST use the wrapper functions in
common/json.go:common.Marshal(),common.Unmarshal()... Do NOT directly import or callencoding/jsonin business code."
256-284:⚠️ Potential issue | 🔴 CriticalReplace direct
json.Marshal/json.Unmarshalcalls withcommon.Marshalandcommon.Unmarshalwrappers.Lines 276 and 280 use
json.Marshal()andjson.Unmarshal()directly. Per coding guidelines, all JSON operations must use the wrapper functions fromcommon/json.go:common.Marshal()andcommon.Unmarshal(). Apply this fix to all JSON operations in this file.The metadata unmarshal pattern for
SoundandWatermarkInfois correct — these fields are intentionally populated via the metadata pass-through mechanism, which is consistent withTaskSubmitReq.Metadatabeingmap[string]interface{}.
https://app.klingai.com/cn/dev/document-api/apiReference/model/textToVideo

sound=on
mode=pro
Summary by CodeRabbit