Skip to content

Commit

Permalink
Merge pull request scylladb#301 from illia-li/il/fix/marshal/nil_refe…
Browse files Browse the repository at this point in the history
…rence

Fix unmarshall errors, add condition for `nil reference`
  • Loading branch information
dkropachev authored Oct 11, 2024
2 parents 79792d0 + aaea3eb commit 434b37a
Show file tree
Hide file tree
Showing 15 changed files with 368 additions and 64 deletions.
6 changes: 3 additions & 3 deletions serialization/bigint/marshal_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func EncString(v string) ([]byte, error) {

n, err := strconv.ParseInt(v, 10, 64)
if err != nil {
return nil, fmt.Errorf("failed to marshal bigint: can not marshal %#v %s", v, err)
return nil, fmt.Errorf("failed to marshal bigint: can not marshal (%T)(%[1]v) %s", v, err)
}
return encInt64(n), nil
}
Expand All @@ -181,11 +181,11 @@ func EncReflect(v reflect.Value) ([]byte, error) {
}
n, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return nil, fmt.Errorf("failed to marshal bigint: can not marshal %#v %s", v.Interface(), err)
return nil, fmt.Errorf("failed to marshal bigint: can not marshal (%T)(%[1]v) %s", v.Interface(), err)
}
return encInt64(n), nil
default:
return nil, fmt.Errorf("failed to marshal bigint: unsupported value type (%T)(%#[1]v)", v.Interface())
return nil, fmt.Errorf("failed to marshal bigint: unsupported value type (%T)(%[1]v)", v.Interface())
}
}

Expand Down
2 changes: 1 addition & 1 deletion serialization/bigint/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func Unmarshal(data []byte, value interface{}) error {
rv := reflect.ValueOf(value)
rt := rv.Type()
if rt.Kind() != reflect.Ptr {
return fmt.Errorf("failed to unmarshal bigint: unsupported value type (%T)(%#[1]v)", value)
return fmt.Errorf("failed to unmarshal bigint: unsupported value type (%T)(%[1]v)", value)
}
if rt.Elem().Kind() != reflect.Ptr {
return DecReflect(data, rv)
Expand Down
Loading

0 comments on commit 434b37a

Please sign in to comment.