Skip to content

Commit

Permalink
Follow @rogpeppe suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
sixstone-qq committed Nov 24, 2021
1 parent 573d26c commit 8213d14
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,15 @@ func (d *decoder) eval(target reflect.Value) {
}
case vm.String:
if target.Type() == uuidType {
if frame.String == "" {
// We produce the empty string "" when encoding zero UUID value,
// so allow it when decoding too.
target.Set(reflect.ValueOf(gouuid.UUID{}))
break
}
val, err := gouuid.Parse(frame.String)
if err != nil {
if len(frame.String) != 0 {
d.error(fmt.Errorf("invalid UUID in Avro encoding: %w", err))
} // We allow written "" on encoding zero UUID value, so we do in decoding part
d.error(fmt.Errorf("invalid UUID in Avro encoding: %w", err))
} else {
target.Set(reflect.ValueOf(val))
}
Expand Down

0 comments on commit 8213d14

Please sign in to comment.