Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix bug about unit type #826

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions pkg/component/base/executionwrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/data/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Loading