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 } 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: