Commit 799de43c by Seefs

fix: Return the original payload and nil error on Unmarshal or Marshal failures…

fix: Return the original payload and nil error on Unmarshal or Marshal failures in RemoveDisabledFields
parent d075fbee
...@@ -515,7 +515,8 @@ type TaskInfo struct { ...@@ -515,7 +515,8 @@ type TaskInfo struct {
func RemoveDisabledFields(jsonData []byte, channelOtherSettings dto.ChannelOtherSettings) ([]byte, error) { func RemoveDisabledFields(jsonData []byte, channelOtherSettings dto.ChannelOtherSettings) ([]byte, error) {
var data map[string]interface{} var data map[string]interface{}
if err := common.Unmarshal(jsonData, &data); err != nil { if err := common.Unmarshal(jsonData, &data); err != nil {
return jsonData, err common.SysError("RemoveDisabledFields Unmarshal error :" + err.Error())
return jsonData, nil
} }
// 默认移除 service_tier,除非明确允许(避免额外计费风险) // 默认移除 service_tier,除非明确允许(避免额外计费风险)
...@@ -539,5 +540,10 @@ func RemoveDisabledFields(jsonData []byte, channelOtherSettings dto.ChannelOther ...@@ -539,5 +540,10 @@ func RemoveDisabledFields(jsonData []byte, channelOtherSettings dto.ChannelOther
} }
} }
return common.Marshal(data) jsonDataAfter, err := common.Marshal(data)
if err != nil {
common.SysError("RemoveDisabledFields Marshal error :" + err.Error())
return jsonData, nil
}
return jsonDataAfter, nil
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment