Skip to content

Commit

Permalink
Fix Required.Proto2.JsonInput.AllFieldAcceptNull conformance (#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcready authored Jul 8, 2024
1 parent 1798e0d commit 91917f6
Show file tree
Hide file tree
Showing 38 changed files with 1,161 additions and 445 deletions.
4 changes: 4 additions & 0 deletions packages/runtime/src/reflection-json-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,17 @@ export class ReflectionJsonReader {
break;

case "enum":
if (jsonValue === null)
continue;
let val = this.enum(field.T(), jsonValue, field.name, options.ignoreUnknownFields);
if (val === false)
continue;
target[localName] = val;
break;

case "scalar":
if (jsonValue === null)
continue;
target[localName] = this.scalar(jsonValue, field.T, field.L, field.name);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/test-conformance/download-conformance-runner.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if [ -f "bin/conformance_test_runner" ]; then
exit 0;
fi

GOOGLE_PROTOBUF_VERSION=22.3
GOOGLE_PROTOBUF_VERSION=27.2
UNAME_OS=$(uname -s)
if [[ "$UNAME_OS" == "Darwin" ]]; then
PLATFORM=osx-x86_64
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.0 with parameter long_type_bigint,optimize_code_size,generate_dependencies
// @generated by protobuf-ts 2.9.4 with parameter long_type_bigint,optimize_code_size,generate_dependencies
// @generated from protobuf file "conformance/conformance.proto" (package "conformance", syntax proto3)
// tslint:disable
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.0 with parameter long_type_bigint,optimize_code_size,generate_dependencies
// @generated by protobuf-ts 2.9.4 with parameter long_type_bigint,optimize_code_size,generate_dependencies
// @generated from protobuf file "google/protobuf/any.proto" (package "google.protobuf", syntax proto3)
// tslint:disable
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.0 with parameter long_type_bigint,optimize_code_size,generate_dependencies
// @generated by protobuf-ts 2.9.4 with parameter long_type_bigint,optimize_code_size,generate_dependencies
// @generated from protobuf file "google/protobuf/duration.proto" (package "google.protobuf", syntax proto3)
// tslint:disable
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.0 with parameter long_type_bigint,optimize_code_size,generate_dependencies
// @generated by protobuf-ts 2.9.4 with parameter long_type_bigint,optimize_code_size,generate_dependencies
// @generated from protobuf file "google/protobuf/field_mask.proto" (package "google.protobuf", syntax proto3)
// tslint:disable
//
Expand Down Expand Up @@ -260,8 +260,9 @@ class FieldMask$Type extends MessageType<FieldMask> {
* Encode `FieldMask` to JSON object.
*/
internalJsonWrite(message: FieldMask, options: JsonWriteOptions): JsonValue {
const invalidFieldMaskJsonRegex = /[A-Z]|(_([.0-9_]|$))/g;
return message.paths.map(p => {
if (p.match(/_[0-9]?_/g) || p.match(/[A-Z]/g))
if (invalidFieldMaskJsonRegex.test(p))
throw new Error("Unable to encode FieldMask to JSON. lowerCamelCase of path name \"" + p + "\" is irreversible.");
return lowerCamelCase(p);
}).join(",");
Expand All @@ -280,7 +281,7 @@ class FieldMask$Type extends MessageType<FieldMask> {
if (str.includes("_"))
throw new Error("Unable to parse FieldMask from JSON. Path names must be lowerCamelCase.");
let sc = str.replace(/[A-Z]/g, letter => "_" + letter.toLowerCase());
return (sc[0] === "_") ? sc.substring(1) : sc;
return sc;
};
target.paths = json.split(",").map(camelToSnake);
return target;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.0 with parameter long_type_bigint,optimize_code_size,generate_dependencies
// @generated by protobuf-ts 2.9.4 with parameter long_type_bigint,optimize_code_size,generate_dependencies
// @generated from protobuf file "google/protobuf/struct.proto" (package "google.protobuf", syntax proto3)
// tslint:disable
//
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.0 with parameter long_type_bigint,optimize_code_size,generate_dependencies
// @generated by protobuf-ts 2.9.4 with parameter long_type_bigint,optimize_code_size,generate_dependencies
// @generated from protobuf file "google/protobuf/timestamp.proto" (package "google.protobuf", syntax proto3)
// tslint:disable
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.0 with parameter long_type_bigint,optimize_code_size,generate_dependencies
// @generated by protobuf-ts 2.9.4 with parameter long_type_bigint,optimize_code_size,generate_dependencies
// @generated from protobuf file "google/protobuf/wrappers.proto" (package "google.protobuf", syntax proto3)
// tslint:disable
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.0 with parameter long_type_string,optimize_code_size,generate_dependencies
// @generated by protobuf-ts 2.9.4 with parameter long_type_string,optimize_code_size,generate_dependencies
// @generated from protobuf file "conformance/conformance.proto" (package "conformance", syntax proto3)
// tslint:disable
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.0 with parameter long_type_string,optimize_code_size,generate_dependencies
// @generated by protobuf-ts 2.9.4 with parameter long_type_string,optimize_code_size,generate_dependencies
// @generated from protobuf file "google/protobuf/any.proto" (package "google.protobuf", syntax proto3)
// tslint:disable
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.0 with parameter long_type_string,optimize_code_size,generate_dependencies
// @generated by protobuf-ts 2.9.4 with parameter long_type_string,optimize_code_size,generate_dependencies
// @generated from protobuf file "google/protobuf/duration.proto" (package "google.protobuf", syntax proto3)
// tslint:disable
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.0 with parameter long_type_string,optimize_code_size,generate_dependencies
// @generated by protobuf-ts 2.9.4 with parameter long_type_string,optimize_code_size,generate_dependencies
// @generated from protobuf file "google/protobuf/field_mask.proto" (package "google.protobuf", syntax proto3)
// tslint:disable
//
Expand Down Expand Up @@ -260,8 +260,9 @@ class FieldMask$Type extends MessageType<FieldMask> {
* Encode `FieldMask` to JSON object.
*/
internalJsonWrite(message: FieldMask, options: JsonWriteOptions): JsonValue {
const invalidFieldMaskJsonRegex = /[A-Z]|(_([.0-9_]|$))/g;
return message.paths.map(p => {
if (p.match(/_[0-9]?_/g) || p.match(/[A-Z]/g))
if (invalidFieldMaskJsonRegex.test(p))
throw new Error("Unable to encode FieldMask to JSON. lowerCamelCase of path name \"" + p + "\" is irreversible.");
return lowerCamelCase(p);
}).join(",");
Expand All @@ -280,7 +281,7 @@ class FieldMask$Type extends MessageType<FieldMask> {
if (str.includes("_"))
throw new Error("Unable to parse FieldMask from JSON. Path names must be lowerCamelCase.");
let sc = str.replace(/[A-Z]/g, letter => "_" + letter.toLowerCase());
return (sc[0] === "_") ? sc.substring(1) : sc;
return sc;
};
target.paths = json.split(",").map(camelToSnake);
return target;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.0 with parameter long_type_string,optimize_code_size,generate_dependencies
// @generated by protobuf-ts 2.9.4 with parameter long_type_string,optimize_code_size,generate_dependencies
// @generated from protobuf file "google/protobuf/struct.proto" (package "google.protobuf", syntax proto3)
// tslint:disable
//
Expand Down
Loading

0 comments on commit 91917f6

Please sign in to comment.