From 703c5ff261808a7b9b1ccfda4c082ae26beb04d9 Mon Sep 17 00:00:00 2001 From: "zhaoxun.3233" Date: Thu, 6 Nov 2025 14:38:15 +0800 Subject: [PATCH 1/6] add validateCreateTaskReq --- backend/modules/observability/application/task.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/modules/observability/application/task.go b/backend/modules/observability/application/task.go index d71be1a49..5900639a2 100644 --- a/backend/modules/observability/application/task.go +++ b/backend/modules/observability/application/task.go @@ -191,6 +191,9 @@ func (t *TaskApplication) validateCreateTaskReq(ctx context.Context, req *task.C return errorx.NewByCode(obErrorx.CommercialCommonInvalidParamCodeCode, errorx.WithExtraMsg("The start time must be earlier than the end time.")) } } + if req.GetTask().GetRule().GetSampler().GetIsCycle() && req.GetTask().GetRule().GetSampler().GetCycleInterval() == 0 { + return errorx.NewByCode(obErrorx.CommercialCommonInvalidParamCodeCode, errorx.WithExtraMsg("invalid cycle_interval")) + } return nil } From 85207ba30d54aac653243391c771f4c0cb046d43 Mon Sep 17 00:00:00 2001 From: "zhaoxun.3233" Date: Fri, 7 Nov 2025 14:58:23 +0800 Subject: [PATCH 2/6] fix mutilpart proc --- .../task/service/taskexe/processor/utils.go | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/modules/observability/domain/task/service/taskexe/processor/utils.go b/backend/modules/observability/domain/task/service/taskexe/processor/utils.go index 2c74b334e..1e87c9b81 100644 --- a/backend/modules/observability/domain/task/service/taskexe/processor/utils.go +++ b/backend/modules/observability/domain/task/service/taskexe/processor/utils.go @@ -202,7 +202,7 @@ func buildItem(ctx context.Context, span *loop_span.Span, fieldMappings []*task_ logs.CtxInfo(ctx, "Evaluator field name is nil") continue } - var evaluationSetSchemas []*eval_set.FieldSchema + var evaluationSetSchemas []*entity.FieldSchema if evaluationSetSchema == "" { logs.CtxInfo(ctx, "Evaluation set schema is nil") continue @@ -213,10 +213,10 @@ func buildItem(ctx context.Context, span *loop_span.Span, fieldMappings []*task_ continue } for _, fieldSchema := range evaluationSetSchemas { - if fieldSchema.GetKey() == *mapping.EvalSetName { - key := fieldSchema.GetKey() - if key == "" { - logs.CtxInfo(ctx, "Evaluator field key is empty, name:%v", *mapping.FieldSchema.Name) + if fieldSchema.Key == mapping.EvalSetName { + key := fieldSchema.Key + if key == nil { + logs.CtxInfo(ctx, "Evaluator field key is empty, name:%v", fieldSchema.Name) continue } value, err := span.ExtractByJsonpath(ctx, mapping.TraceFieldKey, mapping.TraceFieldJsonpath) @@ -224,14 +224,14 @@ func buildItem(ctx context.Context, span *loop_span.Span, fieldMappings []*task_ logs.CtxInfo(ctx, "Extract field failed, err:%v", err) continue } - content, err := GetContentInfo(ctx, fieldSchema.GetContentType(), value) + content, err := GetContentInfo(ctx, fieldSchema.ContentType, value) if err != nil { logs.CtxInfo(ctx, "GetContentInfo failed, err:%v", err) return nil } fieldDatas = append(fieldDatas, &eval_set.FieldData{ - Key: gptr.Of(key), - Name: gptr.Of(fieldSchema.GetName()), + Key: key, + Name: gptr.Of(fieldSchema.Name), Content: content, }) } @@ -241,10 +241,10 @@ func buildItem(ctx context.Context, span *loop_span.Span, fieldMappings []*task_ } // todo:[xun]和手动回流的代码逻辑一样,需要抽取公共代码 -func GetContentInfo(ctx context.Context, contentType common.ContentType, value string) (*common.Content, error) { +func GetContentInfo(ctx context.Context, contentType entity.ContentType, value string) (*common.Content, error) { var content *common.Content switch contentType { - case common.ContentTypeMultiPart: + case entity.ContentType_MultiPart: var parts []tracespec.ModelMessagePart err := json.Unmarshal([]byte(value), &parts) if err != nil { From 75692f853a6b2945939c09dc82839bff5031ab27 Mon Sep 17 00:00:00 2001 From: "zhaoxun.3233" Date: Fri, 7 Nov 2025 15:06:29 +0800 Subject: [PATCH 3/6] fix muti part proc --- .../domain/task/service/taskexe/processor/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/modules/observability/domain/task/service/taskexe/processor/utils.go b/backend/modules/observability/domain/task/service/taskexe/processor/utils.go index 1e87c9b81..8b9a497d1 100644 --- a/backend/modules/observability/domain/task/service/taskexe/processor/utils.go +++ b/backend/modules/observability/domain/task/service/taskexe/processor/utils.go @@ -213,7 +213,7 @@ func buildItem(ctx context.Context, span *loop_span.Span, fieldMappings []*task_ continue } for _, fieldSchema := range evaluationSetSchemas { - if fieldSchema.Key == mapping.EvalSetName { + if *fieldSchema.Key == *mapping.EvalSetName { key := fieldSchema.Key if key == nil { logs.CtxInfo(ctx, "Evaluator field key is empty, name:%v", fieldSchema.Name) From f841a9888d4e46323043a76ca5929786bebc30b2 Mon Sep 17 00:00:00 2001 From: "zhaoxun.3233" Date: Fri, 7 Nov 2025 16:29:00 +0800 Subject: [PATCH 4/6] fix ut --- .../task/service/taskexe/processor/utils_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/modules/observability/domain/task/service/taskexe/processor/utils_test.go b/backend/modules/observability/domain/task/service/taskexe/processor/utils_test.go index d4c6a33b3..68f5c61ff 100755 --- a/backend/modules/observability/domain/task/service/taskexe/processor/utils_test.go +++ b/backend/modules/observability/domain/task/service/taskexe/processor/utils_test.go @@ -213,11 +213,11 @@ func TestBuildItem(t *testing.T) { TraceFieldJsonpath: "", EvalSetName: gptr.Of("field_1"), } - evalSchema := []*eval_set.FieldSchema{ + evalSchema := []*entity.FieldSchema{ { Key: gptr.Of("field_1"), - Name: gptr.Of("field_1"), - ContentType: gptr.Of(common.ContentTypeText), + Name: "field_1", + ContentType: common.ContentTypeText, }, } evalSchemaBytes, err := json.Marshal(evalSchema) @@ -235,11 +235,11 @@ func TestBuildItem(t *testing.T) { // content error path should return nil mapping.FieldSchema.ContentType = gptr.Of(common.ContentTypeMultiPart) badSpan := &loop_span.Span{TraceID: span.TraceID, SpanID: span.SpanID, Input: "invalid json"} - badSchema := []*eval_set.FieldSchema{ + badSchema := []*entity.FieldSchema{ { Key: gptr.Of("field_1"), - Name: gptr.Of("field_1"), - ContentType: gptr.Of(common.ContentTypeMultiPart), + Name: "field_1", + ContentType: common.ContentTypeMultiPart, }, } badBytes, err := json.Marshal(badSchema) From 53cdb67a3f7725c087d9a8787b862784f435c0f8 Mon Sep 17 00:00:00 2001 From: "zhaoxun.3233" Date: Fri, 7 Nov 2025 17:21:08 +0800 Subject: [PATCH 5/6] fix ut --- .../domain/task/service/taskexe/processor/utils_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/modules/observability/domain/task/service/taskexe/processor/utils_test.go b/backend/modules/observability/domain/task/service/taskexe/processor/utils_test.go index 68f5c61ff..0d480490b 100755 --- a/backend/modules/observability/domain/task/service/taskexe/processor/utils_test.go +++ b/backend/modules/observability/domain/task/service/taskexe/processor/utils_test.go @@ -279,11 +279,11 @@ func TestBuildItems(t *testing.T) { goodSpan := &loop_span.Span{TraceID: "1234567890abcdef1234567890abcdef", SpanID: "deadc0debeefcafe", Input: "hello"} badSpan := &loop_span.Span{TraceID: goodSpan.TraceID, SpanID: "badbadbadbadbad", Input: "invalid"} mapping.FieldSchema.ContentType = gptr.Of(common.ContentTypeMultiPart) - multipartSchema := []*eval_set.FieldSchema{ + multipartSchema := []*entity.FieldSchema{ { Key: gptr.Of("field_1"), - Name: gptr.Of("field_1"), - ContentType: gptr.Of(common.ContentTypeMultiPart), + Name: "field_1", + ContentType: common.ContentTypeMultiPart, }, } multipartBytes, err := json.Marshal(multipartSchema) From a7080854d4ab0f39ce429dc01abf7e94f7ea2f53 Mon Sep 17 00:00:00 2001 From: "zhaoxun.3233" Date: Fri, 7 Nov 2025 17:42:35 +0800 Subject: [PATCH 6/6] fix ut --- .../task/service/taskexe/processor/auto_evaluate_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/modules/observability/domain/task/service/taskexe/processor/auto_evaluate_test.go b/backend/modules/observability/domain/task/service/taskexe/processor/auto_evaluate_test.go index bf2298646..c7c8c3397 100755 --- a/backend/modules/observability/domain/task/service/taskexe/processor/auto_evaluate_test.go +++ b/backend/modules/observability/domain/task/service/taskexe/processor/auto_evaluate_test.go @@ -16,7 +16,6 @@ import ( "github.com/coze-dev/coze-loop/backend/infra/middleware/session" "github.com/coze-dev/coze-loop/backend/kitex_gen/coze/loop/evaluation/domain/common" - "github.com/coze-dev/coze-loop/backend/kitex_gen/coze/loop/evaluation/domain/eval_set" "github.com/coze-dev/coze-loop/backend/kitex_gen/coze/loop/observability/domain/dataset" "github.com/coze-dev/coze-loop/backend/kitex_gen/coze/loop/observability/domain/task" "github.com/coze-dev/coze-loop/backend/modules/observability/domain/component/rpc" @@ -192,11 +191,12 @@ func buildSpan(input string) *loop_span.Span { func makeSchemaJSON(t *testing.T, fieldName string, contentType common.ContentType) string { t.Helper() - fieldSchemas := []*eval_set.FieldSchema{ + fieldSchemas := []traceentity.FieldSchema{ { Key: gptr.Of(fieldName), - Name: gptr.Of(fieldName), - ContentType: gptr.Of(contentType), + Name: fieldName, + ContentType: traceentity.ContentType(contentType), + TextSchema: "{}", }, } bytes, err := json.Marshal(fieldSchemas)