When converting a field mask to JSON, path values with a trailing underscore are converted instead of being rejected.
import { create, toJson, fromJson } from "@bufbuild/protobuf";
import { FieldMaskSchema } from "@bufbuild/protobuf/wkt";
var msg = create(FieldMaskSchema, { paths: ["abc_"] });
console.log(msg);
var json = toJson(FieldMaskSchema, msg); // Should fail but works
console.log(json);
var msg2 = fromJson(FieldMaskSchema, json); // The underscore is lost
console.log(msg2);
In the same situation, the official Python implementation fails:
from google.protobuf.field_mask_pb2 import FieldMask
from google.protobuf.json_format import MessageToJson
msg = FieldMask(paths=["abc_"])
MessageToJson(msg) # ValueError: Fail to print FieldMask to Json string: Trailing "_" in path name abc_.
When converting a field mask to JSON, path values with a trailing underscore are converted instead of being rejected.
In the same situation, the official Python implementation fails: