From 08a5243bbc04dbf48906c88d4fc6457ba62eb49a Mon Sep 17 00:00:00 2001 From: feitianbubu Date: Fri, 27 Mar 2026 17:24:26 +0800 Subject: [PATCH 1/2] feat: TaskSubmitReq support Duration --- relay/common/relay_info.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/relay/common/relay_info.go b/relay/common/relay_info.go index e4421fc1..7d4f063c 100644 --- a/relay/common/relay_info.go +++ b/relay/common/relay_info.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + "strconv" "strings" "time" @@ -690,6 +691,7 @@ func (t *TaskSubmitReq) UnmarshalJSON(data []byte) error { type Alias TaskSubmitReq aux := &struct { Metadata json.RawMessage `json:"metadata,omitempty"` + Duration json.RawMessage `json:"duration,omitempty"` *Alias }{ Alias: (*Alias)(t), @@ -699,6 +701,20 @@ func (t *TaskSubmitReq) UnmarshalJSON(data []byte) error { return err } + if len(aux.Duration) > 0 { + var durationInt int + if err := common.Unmarshal(aux.Duration, &durationInt); err == nil { + t.Duration = durationInt + } else { + var durationStr string + if err := common.Unmarshal(aux.Duration, &durationStr); err == nil && durationStr != "" { + if v, err := strconv.Atoi(durationStr); err == nil { + t.Duration = v + } + } + } + } + if len(aux.Metadata) > 0 { var metadataStr string if err := common.Unmarshal(aux.Metadata, &metadataStr); err == nil && metadataStr != "" { From b713e277cdc5a41e22abf2831976d61f26153052 Mon Sep 17 00:00:00 2001 From: feitianbubu Date: Fri, 3 Apr 2026 15:25:57 +0800 Subject: [PATCH 2/2] feat: metadata correct parse --- relay/common/relay_utils.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/relay/common/relay_utils.go b/relay/common/relay_utils.go index 3cbb18c2..18df77a6 100644 --- a/relay/common/relay_utils.go +++ b/relay/common/relay_utils.go @@ -204,7 +204,9 @@ func ValidateBasicTaskRequest(c *gin.Context, info *RelayInfo, action string) *d if err != nil { return createTaskError(err, "invalid_multipart_form", http.StatusBadRequest, true) } - } else if err := common.UnmarshalBodyReusable(c, &req); err != nil { + } + // 为了metadata字段的兼容性,统一UnmarshalBodyReusable + if err := common.UnmarshalBodyReusable(c, &req); err != nil { return createTaskError(err, "invalid_request", http.StatusBadRequest, true) }