From b45ec2f874aecb2e5dd9b48ea48afeb44947089a Mon Sep 17 00:00:00 2001 From: chuang8511 Date: Fri, 8 Nov 2024 15:20:44 +0000 Subject: [PATCH 1/2] fix: fix bug about unit type --- pkg/data/struct.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/data/struct.go b/pkg/data/struct.go index 236681499..63e4ee79d 100644 --- a/pkg/data/struct.go +++ b/pkg/data/struct.go @@ -187,6 +187,8 @@ func unmarshalNumber(v format.Number, field reflect.Value) error { field.SetFloat(v.Float64()) case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: field.SetInt(int64(v.Integer())) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + field.SetUint(uint64(v.Integer())) case reflect.Ptr: if field.IsNil() { field.Set(reflect.New(field.Type().Elem())) @@ -277,7 +279,7 @@ func unmarshalToStruct(v Map, field reflect.Value) error { } // unmarshalNull handles unmarshaling of Null values. -func unmarshalNull(v format.Null, field reflect.Value) error { +func unmarshalNull(_ format.Null, field reflect.Value) error { if field.Kind() == reflect.Ptr { field.Set(reflect.Zero(field.Type())) return nil @@ -401,6 +403,8 @@ func marshalValue(v reflect.Value) (format.Value, error) { return NewNumberFromFloat(v.Float()), nil case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return NewNumberFromInteger(int(v.Int())), nil + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return NewNumberFromInteger(int(v.Uint())), nil case reflect.Bool: return NewBoolean(v.Bool()), nil case reflect.String: From 4276ce5808e8e356b34257f0cd14d639633f467e Mon Sep 17 00:00:00 2001 From: chuang8511 Date: Fri, 8 Nov 2024 15:24:40 +0000 Subject: [PATCH 2/2] chore: add debugg logger for in panic --- pkg/component/base/executionwrapper.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/component/base/executionwrapper.go b/pkg/component/base/executionwrapper.go index b58b23a3a..e07a3fd33 100644 --- a/pkg/component/base/executionwrapper.go +++ b/pkg/component/base/executionwrapper.go @@ -3,10 +3,13 @@ package base import ( "context" "fmt" + "log" + "runtime" "sync" - "github.com/instill-ai/pipeline-backend/pkg/data" "google.golang.org/protobuf/types/known/structpb" + + "github.com/instill-ai/pipeline-backend/pkg/data" ) var _ IExecution = &ExecutionWrapper{} @@ -200,7 +203,13 @@ func ConcurrentExecutor(ctx context.Context, jobs []*Job, execute func(context.C func recoverJobError(ctx context.Context, job *Job) { if r := recover(); r != nil { - fmt.Printf("panic: %+v", r) + // For better debugging process for developers, we log the panic and the stack trace + buf := make([]byte, 2048) + n := runtime.Stack(buf, false) + stackTrace := string(buf[:n]) + log.Printf("panic: %+v\n", r) + log.Printf("stack trace: %s\n", stackTrace) + job.Error.Error(ctx, fmt.Errorf("panic: %+v", r)) return }