diff --git a/cmd/conformance/core.lua b/cmd/conformance/core.lua index 5095222b45b6462e1455b25a63f88cbff9d919da..217b4f38310716e948f9b97ea7428f52facc9f11 100644 --- a/cmd/conformance/core.lua +++ b/cmd/conformance/core.lua @@ -24,6 +24,11 @@ ['conformance.FailureSet'] = conformance.FailureSet_descriptor, } +-- Register the test message in the runtime's WKT registry so Any fields +-- with `@type` pointing at a non-WKT user type (the conformance suite uses +-- TestAllTypesProto3 itself inside some Any tests) resolve in JSON decode. +pb.register(proto3_tests.TestAllTypesProto3_descriptor) + local WIRE_FORMAT = conformance.WireFormat local PROTOBUF = WIRE_FORMAT.PROTOBUF local JSON = WIRE_FORMAT.JSON diff --git a/runtime/pb/wkt.lua b/runtime/pb/wkt.lua index 531d9db166b4f0b574028b1fa478dccf715aa795..690fbc07f18b6df9b3fcca7d46f7c3e8935aae3f 100644 --- a/runtime/pb/wkt.lua +++ b/runtime/pb/wkt.lua @@ -563,4 +563,14 @@ M.FieldMask_encode = fieldmask_encode M.FieldMask_decode = fieldmask_decode M.FieldMask_descriptor = {name='google.protobuf.FieldMask', encode=fieldmask_encode, decode=fieldmask_decode} +-- Self-register every WKT so `pb.lookup(type_url)` resolves them without +-- the user having to call `pb.register` explicitly. This is what makes +-- Any-of-WKT JSON decode work out of the box. +for k, v in pairs(M) do + if type(k) == 'string' and k:sub(-11) == '_descriptor' + and type(v) == 'table' and v.name ~= nil then + M.register(v) + end +end + return M diff --git a/test/conformance/known_failures.txt b/test/conformance/known_failures.txt index e15f5793a5132a4e5a82340d6394ec32a927c14a..288c8fc1a3e49a6f6e7582977c260e9af71232da 100644 --- a/test/conformance/known_failures.txt +++ b/test/conformance/known_failures.txt @@ -33,21 +33,11 @@ Recommended.Proto3.ProtobufInput.RejectInvalidUtf8.String.Singular Recommended.Proto3.ProtobufInput.ValidDataOneofBinary.MESSAGE.Merge.ProtobufOutput Required.Proto3.JsonInput.AllFieldAcceptNull.JsonOutput Required.Proto3.JsonInput.AllFieldAcceptNull.ProtobufOutput -Required.Proto3.JsonInput.Any.ProtobufOutput Required.Proto3.JsonInput.AnyNested.JsonOutput -Required.Proto3.JsonInput.AnyNested.ProtobufOutput -Required.Proto3.JsonInput.AnyUnorderedTypeTag.ProtobufOutput -Required.Proto3.JsonInput.AnyWithDuration.ProtobufOutput -Required.Proto3.JsonInput.AnyWithFieldMask.ProtobufOutput Required.Proto3.JsonInput.AnyWithInt32ValueWrapper.JsonOutput -Required.Proto3.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput Required.Proto3.JsonInput.AnyWithStruct.JsonOutput -Required.Proto3.JsonInput.AnyWithStruct.ProtobufOutput -Required.Proto3.JsonInput.AnyWithTimestamp.ProtobufOutput Required.Proto3.JsonInput.AnyWithValueForInteger.JsonOutput -Required.Proto3.JsonInput.AnyWithValueForInteger.ProtobufOutput Required.Proto3.JsonInput.AnyWithValueForJsonObject.JsonOutput -Required.Proto3.JsonInput.AnyWithValueForJsonObject.ProtobufOutput Required.Proto3.JsonInput.FieldNameInSnakeCase.ProtobufOutput Required.Proto3.JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput Required.Proto3.JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput