blob: 38092acb67661c921b12bad24b1e368c796ce9b7 [file] [log] [blame]
Herbie Ong800c9902018-12-06 15:28:53 -08001// Copyright 2018 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package textpb
6
7import (
8 "fmt"
Herbie Ong0dcfb9a2019-01-14 15:32:26 -08009 "strings"
Herbie Ong21a39742019-04-08 17:32:44 -070010 "unicode/utf8"
Herbie Ong800c9902018-12-06 15:28:53 -080011
12 "github.com/golang/protobuf/v2/internal/encoding/text"
13 "github.com/golang/protobuf/v2/internal/errors"
Herbie Onge1e34932019-03-29 01:05:57 -070014 "github.com/golang/protobuf/v2/internal/fieldnum"
Herbie Ong800c9902018-12-06 15:28:53 -080015 "github.com/golang/protobuf/v2/internal/pragma"
16 "github.com/golang/protobuf/v2/internal/set"
17 "github.com/golang/protobuf/v2/proto"
18 pref "github.com/golang/protobuf/v2/reflect/protoreflect"
Herbie Ongc525c972018-12-18 18:04:31 -080019 "github.com/golang/protobuf/v2/reflect/protoregistry"
Herbie Ong800c9902018-12-06 15:28:53 -080020)
21
22// Unmarshal reads the given []byte into the given proto.Message.
Herbie Ong800c9902018-12-06 15:28:53 -080023func Unmarshal(m proto.Message, b []byte) error {
24 return UnmarshalOptions{}.Unmarshal(m, b)
25}
26
Herbie Ong42577ea2019-03-26 16:26:22 -070027// UnmarshalOptions is a configurable textproto format unmarshaler.
Herbie Ong800c9902018-12-06 15:28:53 -080028type UnmarshalOptions struct {
29 pragma.NoUnkeyedLiterals
Herbie Ongc525c972018-12-18 18:04:31 -080030
Herbie Ong42577ea2019-03-26 16:26:22 -070031 // AllowPartial accepts input for messages that will result in missing
32 // required fields. If AllowPartial is false (the default), Unmarshal will
33 // return error if there are any missing required fields.
34 AllowPartial bool
35
Herbie Ongc525c972018-12-18 18:04:31 -080036 // Resolver is the registry used for type lookups when unmarshaling extensions
37 // and processing Any. If Resolver is not set, unmarshaling will default to
38 // using protoregistry.GlobalTypes.
39 Resolver *protoregistry.Types
Herbie Ong800c9902018-12-06 15:28:53 -080040}
41
42// Unmarshal reads the given []byte and populates the given proto.Message using options in
43// UnmarshalOptions object.
44func (o UnmarshalOptions) Unmarshal(m proto.Message, b []byte) error {
45 var nerr errors.NonFatal
46
47 mr := m.ProtoReflect()
48 // Clear all fields before populating it.
49 // TODO: Determine if this needs to be consistent with jsonpb and binary unmarshal where
50 // behavior is to merge values into existing message. If decision is to not clear the fields
51 // ahead, code will need to be updated properly when merging nested messages.
52 resetMessage(mr)
53
54 // Parse into text.Value of message type.
55 val, err := text.Unmarshal(b)
56 if !nerr.Merge(err) {
57 return err
58 }
59
Herbie Ongc525c972018-12-18 18:04:31 -080060 if o.Resolver == nil {
61 o.Resolver = protoregistry.GlobalTypes
62 }
Herbie Ong800c9902018-12-06 15:28:53 -080063 err = o.unmarshalMessage(val.Message(), mr)
64 if !nerr.Merge(err) {
65 return err
66 }
67
Damien Neil4686e232019-04-05 13:31:40 -070068 if !o.AllowPartial {
69 nerr.Merge(proto.IsInitialized(m))
70 }
71
Herbie Ong800c9902018-12-06 15:28:53 -080072 return nerr.E
73}
74
75// resetMessage clears all fields of given protoreflect.Message.
76// TODO: This should go into the proto package.
77func resetMessage(m pref.Message) {
78 knownFields := m.KnownFields()
79 knownFields.Range(func(num pref.FieldNumber, _ pref.Value) bool {
80 knownFields.Clear(num)
81 return true
82 })
83 unknownFields := m.UnknownFields()
84 unknownFields.Range(func(num pref.FieldNumber, _ pref.RawFields) bool {
85 unknownFields.Set(num, nil)
86 return true
87 })
Herbie Ong800c9902018-12-06 15:28:53 -080088 extTypes := knownFields.ExtensionTypes()
89 extTypes.Range(func(xt pref.ExtensionType) bool {
90 extTypes.Remove(xt)
91 return true
92 })
93}
94
95// unmarshalMessage unmarshals a [][2]text.Value message into the given protoreflect.Message.
96func (o UnmarshalOptions) unmarshalMessage(tmsg [][2]text.Value, m pref.Message) error {
97 var nerr errors.NonFatal
98
Joe Tsai0fc49f82019-05-01 12:29:25 -070099 messageDesc := m.Descriptor()
Herbie Ong66c365c2019-01-04 14:08:41 -0800100 knownFields := m.KnownFields()
101
102 // Handle expanded Any message.
Joe Tsai0fc49f82019-05-01 12:29:25 -0700103 if messageDesc.FullName() == "google.protobuf.Any" && isExpandedAny(tmsg) {
Herbie Ong66c365c2019-01-04 14:08:41 -0800104 return o.unmarshalAny(tmsg[0], knownFields)
105 }
106
Joe Tsai0fc49f82019-05-01 12:29:25 -0700107 fieldDescs := messageDesc.Fields()
108 reservedNames := messageDesc.ReservedNames()
Herbie Ongc525c972018-12-18 18:04:31 -0800109 xtTypes := knownFields.ExtensionTypes()
Herbie Ong800c9902018-12-06 15:28:53 -0800110 var seenNums set.Ints
Herbie Ong8a1d4602019-04-02 20:19:36 -0700111 var seenOneofs set.Ints
Herbie Ong800c9902018-12-06 15:28:53 -0800112
113 for _, tfield := range tmsg {
114 tkey := tfield[0]
115 tval := tfield[1]
116
117 var fd pref.FieldDescriptor
Herbie Ongc525c972018-12-18 18:04:31 -0800118 var name pref.Name
119 switch tkey.Type() {
120 case text.Name:
121 name, _ = tkey.Name()
Herbie Ong800c9902018-12-06 15:28:53 -0800122 fd = fieldDescs.ByName(name)
Herbie Ong0dcfb9a2019-01-14 15:32:26 -0800123 if fd == nil {
124 // Check if this is a group field.
125 fd = fieldDescs.ByName(pref.Name(strings.ToLower(string(name))))
126 }
Herbie Ongc525c972018-12-18 18:04:31 -0800127 case text.String:
Herbie Ong66c365c2019-01-04 14:08:41 -0800128 // Handle extensions only. This code path is not for Any.
Joe Tsai0fc49f82019-05-01 12:29:25 -0700129 if messageDesc.FullName() == "google.protobuf.Any" {
Herbie Ong66c365c2019-01-04 14:08:41 -0800130 break
131 }
132 // Extensions have to be registered first in the message's
Herbie Ongc525c972018-12-18 18:04:31 -0800133 // ExtensionTypes before setting a value to it.
134 xtName := pref.FullName(tkey.String())
Herbie Ong66c365c2019-01-04 14:08:41 -0800135 // Check first if it is already registered. This is the case for
136 // repeated fields.
Herbie Ongc525c972018-12-18 18:04:31 -0800137 xt := xtTypes.ByName(xtName)
138 if xt == nil {
139 var err error
Herbie Ong6470ea62019-01-07 18:56:57 -0800140 xt, err = o.findExtension(xtName)
Herbie Ongc525c972018-12-18 18:04:31 -0800141 if err != nil && err != protoregistry.NotFound {
Herbie Ong66c365c2019-01-04 14:08:41 -0800142 return errors.New("unable to resolve [%v]: %v", xtName, err)
Herbie Ongc525c972018-12-18 18:04:31 -0800143 }
144 if xt != nil {
145 xtTypes.Register(xt)
146 }
147 }
Joe Tsai0fc49f82019-05-01 12:29:25 -0700148 if xt != nil {
149 fd = xt.Descriptor()
150 }
Herbie Ong800c9902018-12-06 15:28:53 -0800151 }
Herbie Ongc525c972018-12-18 18:04:31 -0800152
Herbie Ong800c9902018-12-06 15:28:53 -0800153 if fd == nil {
Herbie Ong7c624e22018-12-13 14:41:22 -0800154 // Ignore reserved names.
155 if reservedNames.Has(name) {
156 continue
157 }
Herbie Ong800c9902018-12-06 15:28:53 -0800158 // TODO: Can provide option to ignore unknown message fields.
Joe Tsai0fc49f82019-05-01 12:29:25 -0700159 return errors.New("%v contains unknown field: %v", messageDesc.FullName(), tkey)
Herbie Ong800c9902018-12-06 15:28:53 -0800160 }
161
162 if cardinality := fd.Cardinality(); cardinality == pref.Repeated {
163 // Map or list fields have cardinality of repeated.
164 if err := o.unmarshalRepeated(tval, fd, knownFields); !nerr.Merge(err) {
165 return err
166 }
167 } else {
Herbie Ong8a1d4602019-04-02 20:19:36 -0700168 // If field is a oneof, check if it has already been set.
Joe Tsaid24bc722019-04-15 23:39:09 -0700169 if od := fd.Oneof(); od != nil {
Herbie Ong8a1d4602019-04-02 20:19:36 -0700170 idx := uint64(od.Index())
171 if seenOneofs.Has(idx) {
172 return errors.New("oneof %v is already set", od.FullName())
173 }
174 seenOneofs.Set(idx)
175 }
176
Herbie Ong800c9902018-12-06 15:28:53 -0800177 // Required or optional fields.
178 num := uint64(fd.Number())
179 if seenNums.Has(num) {
180 return errors.New("non-repeated field %v is repeated", fd.FullName())
181 }
182 if err := o.unmarshalSingular(tval, fd, knownFields); !nerr.Merge(err) {
183 return err
184 }
Herbie Ong800c9902018-12-06 15:28:53 -0800185 seenNums.Set(num)
186 }
187 }
188
Herbie Ong800c9902018-12-06 15:28:53 -0800189 return nerr.E
190}
191
Herbie Ong6470ea62019-01-07 18:56:57 -0800192// findExtension returns protoreflect.ExtensionType from the Resolver if found.
193func (o UnmarshalOptions) findExtension(xtName pref.FullName) (pref.ExtensionType, error) {
194 xt, err := o.Resolver.FindExtensionByName(xtName)
195 if err == nil {
196 return xt, nil
197 }
198
199 // Check if this is a MessageSet extension field.
200 xt, err = o.Resolver.FindExtensionByName(xtName + ".message_set_extension")
201 if err == nil && isMessageSetExtension(xt) {
202 return xt, nil
203 }
204 return nil, protoregistry.NotFound
205}
206
Herbie Ong800c9902018-12-06 15:28:53 -0800207// unmarshalSingular unmarshals given text.Value into the non-repeated field.
208func (o UnmarshalOptions) unmarshalSingular(input text.Value, fd pref.FieldDescriptor, knownFields pref.KnownFields) error {
209 num := fd.Number()
210
211 var nerr errors.NonFatal
212 var val pref.Value
213 switch fd.Kind() {
214 case pref.MessageKind, pref.GroupKind:
215 if input.Type() != text.Message {
216 return errors.New("%v contains invalid message/group value: %v", fd.FullName(), input)
217 }
Joe Tsai3bc7d6f2019-01-09 02:57:13 -0800218 m := knownFields.NewMessage(num)
Herbie Ong800c9902018-12-06 15:28:53 -0800219 if err := o.unmarshalMessage(input.Message(), m); !nerr.Merge(err) {
220 return err
221 }
222 val = pref.ValueOf(m)
223 default:
224 var err error
225 val, err = unmarshalScalar(input, fd)
226 if !nerr.Merge(err) {
227 return err
228 }
229 }
230 knownFields.Set(num, val)
231
232 return nerr.E
233}
234
235// unmarshalRepeated unmarshals given text.Value into a repeated field. Caller should only
236// call this for cardinality=repeated.
237func (o UnmarshalOptions) unmarshalRepeated(input text.Value, fd pref.FieldDescriptor, knownFields pref.KnownFields) error {
238 var items []text.Value
239 // If input is not a list, turn it into a list.
240 if input.Type() != text.List {
241 items = []text.Value{input}
242 } else {
243 items = input.List()
244 }
245
246 var nerr errors.NonFatal
247 num := fd.Number()
248 val := knownFields.Get(num)
249 if !fd.IsMap() {
250 if err := o.unmarshalList(items, fd, val.List()); !nerr.Merge(err) {
251 return err
252 }
253 } else {
254 if err := o.unmarshalMap(items, fd, val.Map()); !nerr.Merge(err) {
255 return err
256 }
257 }
258
259 return nerr.E
260}
261
262// unmarshalScalar converts the given text.Value to a scalar/enum protoreflect.Value specified in
263// the given FieldDescriptor. Caller should not pass in a FieldDescriptor for a message/group kind.
264func unmarshalScalar(input text.Value, fd pref.FieldDescriptor) (pref.Value, error) {
265 const b32 = false
266 const b64 = true
267
268 switch kind := fd.Kind(); kind {
269 case pref.BoolKind:
270 if b, ok := input.Bool(); ok {
271 return pref.ValueOf(bool(b)), nil
272 }
273 case pref.Int32Kind, pref.Sint32Kind, pref.Sfixed32Kind:
274 if n, ok := input.Int(b32); ok {
275 return pref.ValueOf(int32(n)), nil
276 }
277 case pref.Int64Kind, pref.Sint64Kind, pref.Sfixed64Kind:
278 if n, ok := input.Int(b64); ok {
279 return pref.ValueOf(int64(n)), nil
280 }
281 case pref.Uint32Kind, pref.Fixed32Kind:
282 if n, ok := input.Uint(b32); ok {
283 return pref.ValueOf(uint32(n)), nil
284 }
285 case pref.Uint64Kind, pref.Fixed64Kind:
286 if n, ok := input.Uint(b64); ok {
287 return pref.ValueOf(uint64(n)), nil
288 }
289 case pref.FloatKind:
Herbie Ong250c6ea2019-03-12 20:55:10 -0700290 if n, ok := input.Float(b32); ok {
Herbie Ong800c9902018-12-06 15:28:53 -0800291 return pref.ValueOf(float32(n)), nil
292 }
293 case pref.DoubleKind:
Herbie Ong250c6ea2019-03-12 20:55:10 -0700294 if n, ok := input.Float(b64); ok {
Herbie Ong800c9902018-12-06 15:28:53 -0800295 return pref.ValueOf(float64(n)), nil
296 }
297 case pref.StringKind:
298 if input.Type() == text.String {
Herbie Ong21a39742019-04-08 17:32:44 -0700299 s := input.String()
300 if utf8.ValidString(s) {
301 return pref.ValueOf(s), nil
302 }
303 var nerr errors.NonFatal
304 nerr.AppendInvalidUTF8(string(fd.FullName()))
305 return pref.ValueOf(s), nerr.E
Herbie Ong800c9902018-12-06 15:28:53 -0800306 }
307 case pref.BytesKind:
308 if input.Type() == text.String {
309 return pref.ValueOf([]byte(input.String())), nil
310 }
311 case pref.EnumKind:
312 // If input is int32, use directly.
313 if n, ok := input.Int(b32); ok {
314 return pref.ValueOf(pref.EnumNumber(n)), nil
Herbie Ong66c365c2019-01-04 14:08:41 -0800315 }
316 if name, ok := input.Name(); ok {
317 // Lookup EnumNumber based on name.
Joe Tsaid24bc722019-04-15 23:39:09 -0700318 if enumVal := fd.Enum().Values().ByName(name); enumVal != nil {
Herbie Ong66c365c2019-01-04 14:08:41 -0800319 return pref.ValueOf(enumVal.Number()), nil
Herbie Ong800c9902018-12-06 15:28:53 -0800320 }
321 }
322 default:
323 panic(fmt.Sprintf("invalid scalar kind %v", kind))
324 }
325
326 return pref.Value{}, errors.New("%v contains invalid scalar value: %v", fd.FullName(), input)
327}
328
329// unmarshalList unmarshals given []text.Value into given protoreflect.List.
330func (o UnmarshalOptions) unmarshalList(inputList []text.Value, fd pref.FieldDescriptor, list pref.List) error {
331 var nerr errors.NonFatal
332
333 switch fd.Kind() {
334 case pref.MessageKind, pref.GroupKind:
335 for _, input := range inputList {
336 if input.Type() != text.Message {
337 return errors.New("%v contains invalid message/group value: %v", fd.FullName(), input)
338 }
Joe Tsai3bc7d6f2019-01-09 02:57:13 -0800339 m := list.NewMessage()
Herbie Ong800c9902018-12-06 15:28:53 -0800340 if err := o.unmarshalMessage(input.Message(), m); !nerr.Merge(err) {
341 return err
342 }
343 list.Append(pref.ValueOf(m))
344 }
345 default:
346 for _, input := range inputList {
347 val, err := unmarshalScalar(input, fd)
348 if !nerr.Merge(err) {
349 return err
350 }
351 list.Append(val)
352 }
353 }
354
355 return nerr.E
356}
357
358// unmarshalMap unmarshals given []text.Value into given protoreflect.Map.
359func (o UnmarshalOptions) unmarshalMap(input []text.Value, fd pref.FieldDescriptor, mmap pref.Map) error {
360 var nerr errors.NonFatal
Joe Tsaid24bc722019-04-15 23:39:09 -0700361 fields := fd.Message().Fields()
Herbie Ong800c9902018-12-06 15:28:53 -0800362 keyDesc := fields.ByNumber(1)
363 valDesc := fields.ByNumber(2)
364
365 // Determine ahead whether map entry is a scalar type or a message type in order to call the
366 // appropriate unmarshalMapValue func inside the for loop below.
Herbie Ong66c365c2019-01-04 14:08:41 -0800367 unmarshalMapValue := unmarshalMapScalarValue
Herbie Ong800c9902018-12-06 15:28:53 -0800368 switch valDesc.Kind() {
369 case pref.MessageKind, pref.GroupKind:
370 unmarshalMapValue = o.unmarshalMapMessageValue
371 }
372
373 for _, entry := range input {
374 if entry.Type() != text.Message {
375 return errors.New("%v contains invalid map entry: %v", fd.FullName(), entry)
376 }
377 tkey, tval, err := parseMapEntry(entry.Message(), fd.FullName())
378 if !nerr.Merge(err) {
379 return err
380 }
381 pkey, err := unmarshalMapKey(tkey, keyDesc)
382 if !nerr.Merge(err) {
383 return err
384 }
385 err = unmarshalMapValue(tval, pkey, valDesc, mmap)
386 if !nerr.Merge(err) {
387 return err
388 }
389 }
390
391 return nerr.E
392}
393
394// parseMapEntry parses [][2]text.Value for field names key and value, and return corresponding
395// field values. If there are duplicate field names, the value for the last field is returned. If
396// the field name does not exist, it will return the zero value of text.Value. It will return an
397// error if there are unknown field names.
398func parseMapEntry(mapEntry [][2]text.Value, name pref.FullName) (key text.Value, value text.Value, err error) {
399 for _, field := range mapEntry {
400 keyStr, ok := field[0].Name()
401 if ok {
402 switch keyStr {
403 case "key":
404 if key.Type() != 0 {
405 return key, value, errors.New("%v contains duplicate key field", name)
406 }
407 key = field[1]
408 case "value":
409 if value.Type() != 0 {
410 return key, value, errors.New("%v contains duplicate value field", name)
411 }
412 value = field[1]
413 default:
414 ok = false
415 }
416 }
417 if !ok {
418 // TODO: Do not return error if ignore unknown option is added and enabled.
419 return key, value, errors.New("%v contains unknown map entry name: %v", name, field[0])
420 }
421 }
422 return key, value, nil
423}
424
425// unmarshalMapKey converts given text.Value into a protoreflect.MapKey. A map key type is any
426// integral or string type.
427func unmarshalMapKey(input text.Value, fd pref.FieldDescriptor) (pref.MapKey, error) {
428 // If input is not set, use the zero value.
429 if input.Type() == 0 {
430 return fd.Default().MapKey(), nil
431 }
432
Herbie Ong21a39742019-04-08 17:32:44 -0700433 var nerr errors.NonFatal
Herbie Ong800c9902018-12-06 15:28:53 -0800434 val, err := unmarshalScalar(input, fd)
Herbie Ong21a39742019-04-08 17:32:44 -0700435 if !nerr.Merge(err) {
Herbie Ong800c9902018-12-06 15:28:53 -0800436 return pref.MapKey{}, errors.New("%v contains invalid key: %v", fd.FullName(), input)
437 }
Herbie Ong21a39742019-04-08 17:32:44 -0700438 return val.MapKey(), nerr.E
Herbie Ong800c9902018-12-06 15:28:53 -0800439}
440
441// unmarshalMapMessageValue unmarshals given message-type text.Value into a protoreflect.Map for
442// the given MapKey.
443func (o UnmarshalOptions) unmarshalMapMessageValue(input text.Value, pkey pref.MapKey, _ pref.FieldDescriptor, mmap pref.Map) error {
444 var nerr errors.NonFatal
445 var value [][2]text.Value
446 if input.Type() != 0 {
447 value = input.Message()
448 }
Joe Tsai3bc7d6f2019-01-09 02:57:13 -0800449 m := mmap.NewMessage()
Herbie Ong800c9902018-12-06 15:28:53 -0800450 if err := o.unmarshalMessage(value, m); !nerr.Merge(err) {
451 return err
452 }
453 mmap.Set(pkey, pref.ValueOf(m))
454 return nerr.E
455}
456
457// unmarshalMapScalarValue unmarshals given scalar-type text.Value into a protoreflect.Map
458// for the given MapKey.
Herbie Ong66c365c2019-01-04 14:08:41 -0800459func unmarshalMapScalarValue(input text.Value, pkey pref.MapKey, fd pref.FieldDescriptor, mmap pref.Map) error {
Herbie Ong21a39742019-04-08 17:32:44 -0700460 var nerr errors.NonFatal
Herbie Ong800c9902018-12-06 15:28:53 -0800461 var val pref.Value
462 if input.Type() == 0 {
463 val = fd.Default()
464 } else {
465 var err error
466 val, err = unmarshalScalar(input, fd)
Herbie Ong21a39742019-04-08 17:32:44 -0700467 if !nerr.Merge(err) {
Herbie Ong800c9902018-12-06 15:28:53 -0800468 return err
469 }
470 }
471 mmap.Set(pkey, val)
Herbie Ong21a39742019-04-08 17:32:44 -0700472 return nerr.E
Herbie Ong800c9902018-12-06 15:28:53 -0800473}
Herbie Ong66c365c2019-01-04 14:08:41 -0800474
475// isExpandedAny returns true if given [][2]text.Value may be an expanded Any that contains only one
476// field with key type of text.String type and value type of text.Message.
477func isExpandedAny(tmsg [][2]text.Value) bool {
478 if len(tmsg) != 1 {
479 return false
480 }
481
482 field := tmsg[0]
483 return field[0].Type() == text.String && field[1].Type() == text.Message
484}
485
486// unmarshalAny unmarshals an expanded Any textproto. This method assumes that the given
487// tfield has key type of text.String and value type of text.Message.
488func (o UnmarshalOptions) unmarshalAny(tfield [2]text.Value, knownFields pref.KnownFields) error {
489 var nerr errors.NonFatal
490
491 typeURL := tfield[0].String()
492 value := tfield[1].Message()
493
494 mt, err := o.Resolver.FindMessageByURL(typeURL)
495 if !nerr.Merge(err) {
496 return errors.New("unable to resolve message [%v]: %v", typeURL, err)
497 }
498 // Create new message for the embedded message type and unmarshal the
499 // value into it.
500 m := mt.New()
501 if err := o.unmarshalMessage(value, m); !nerr.Merge(err) {
502 return err
503 }
504 // Serialize the embedded message and assign the resulting bytes to the value field.
Herbie Ong9c100452019-05-06 18:45:33 -0700505 // TODO: If binary marshaling returns required not set error, need to
506 // return another required not set error that contains both the path to this
507 // field and the path inside the embedded message.
Damien Neil96c229a2019-04-03 12:17:24 -0700508 b, err := proto.MarshalOptions{
509 AllowPartial: o.AllowPartial,
510 Deterministic: true,
511 }.Marshal(m.Interface())
Herbie Ong66c365c2019-01-04 14:08:41 -0800512 if !nerr.Merge(err) {
513 return err
514 }
515
Herbie Onge1e34932019-03-29 01:05:57 -0700516 knownFields.Set(fieldnum.Any_TypeUrl, pref.ValueOf(typeURL))
517 knownFields.Set(fieldnum.Any_Value, pref.ValueOf(b))
Herbie Ong66c365c2019-01-04 14:08:41 -0800518
519 return nerr.E
520}