{"record":{"id":"f2792f6f1a291a2c","repo":"XINCGer/Unity3DTraining","slug":"expected","errorCode":null,"errorMessage":"Expected '","messagePattern":"Expected '","errorType":"validation","errorClass":"InvalidProtocolBufferException","httpStatus":null,"severity":"error","filePath":"NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/JsonParser.cs","lineNumber":554,"sourceCode":"            }\n            var data = body.ToByteString();\n\n            // Now that we have the message data, we can pack it into an Any (the message received as a parameter).\n            message.Descriptor.Fields[Any.TypeUrlFieldNumber].Accessor.SetValue(message, typeUrl);\n            message.Descriptor.Fields[Any.ValueFieldNumber].Accessor.SetValue(message, data);\n        }\n\n        // Well-known types end up in a property called \"value\" in the JSON. As there's no longer a @type property\n        // in the given JSON token stream, we should *only* have tokens of start-object, name(\"value\"), the value\n        // itself, and then end-object.\n        private void MergeWellKnownTypeAnyBody(IMessage body, JsonTokenizer tokenizer)\n        {\n            var token = tokenizer.Next(); // Definitely start-object; checked in previous method\n            token = tokenizer.Next();\n            // TODO: What about an absent Int32Value, for example?\n            if (token.Type != JsonToken.TokenType.Name || token.StringValue != JsonFormatter.AnyWellKnownTypeValueField)\n            {\n                throw new InvalidProtocolBufferException(\"Expected '\" + JsonFormatter.AnyWellKnownTypeValueField + \"' property for well-known type Any body\");\n            }\n            Merge(body, tokenizer);\n            token = tokenizer.Next();\n            if (token.Type != JsonToken.TokenType.EndObject)\n            {\n                throw new InvalidProtocolBufferException(\"Expected end-object token after @type/value for well-known type\");\n            }\n        }\n\n        #region Utility methods which don't depend on the state (or settings) of the parser.\n        private static object ParseMapKey(FieldDescriptor field, string keyText)\n        {\n            switch (field.FieldType)\n            {\n                case FieldType.Bool:\n                    if (keyText == \"true\")\n                    {\n                        return true;","sourceCodeStart":536,"sourceCodeEnd":572,"githubUrl":"https://github.com/XINCGer/Unity3DTraining/blob/016f98412ea5e11756b286736f479b66ab6216d5/NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/JsonParser.cs#L536-L572","documentation":"When the JsonParser parses the body of an Any holding a well-known type (e.g. google.protobuf.Timestamp), it expects the JSON object to contain exactly the property named 'value' (JsonFormatter.AnyWellKnownTypeValueField) after '@type'. Any other property name is rejected with this InvalidProtocolBufferException.","triggerScenarios":"Parsing an Any body like {\"@type\":\"type.googleapis.com/google.protobuf.Timestamp\",\"value\":\"...\"} where the second property is misspelled (e.g. 'Value', 'val') or in wrong order/casing, so the first token after @type is not a Name token equal to the canonical field name.","commonSituations":"Hand-crafted or third-party-generated JSON for Any-wrapped well-known types with wrong property casing or naming; serializers that don't follow the canonical Any well-known-type encoding.","solutions":["Rename the inner property to exactly 'value' (the canonical AnyWellKnownTypeValueField).","If you control the producer, serialize well-known types inside Any per the protobuf JSON spec: {\"@type\":\"...\",\"value\":<encoded wkt>}.","Verify JSON casing policy (camelCase) isn't rewriting 'value' to something else."],"exampleFix":"// before\n{\"@type\":\"type.googleapis.com/google.protobuf.Duration\",\"val\":\"5s\"}\n// after\n{\"@type\":\"type.googleapis.com/google.protobuf.Duration\",\"value\":\"5s\"}","handlingStrategy":"validation","validationCode":"// Validate Any well-known-type bodies have the canonical 'value' property\nvar anyObjs = Regex.Matches(json, '\"@type\"\\\\s*:\\\\s*\"[^\"]+\"\\\\s*,\\\\s*\"([^\"]+)\"');\nforeach (Match m in anyObjs)\n    if (m.Groups[1].Value != \"value\") throw new Exception($\"Any body must use 'value', got '{m.Groups[1].Value}'\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var msg = parser.Parse<T>(json);\n}\ncatch (InvalidProtocolBufferException ex) when (ex.Message.Contains(\"property for well-known type Any body\"))\n{\n    // inspect/repair the offending JSON or surface a clear client-side error\n}","preventionTips":["Use protobuf's canonical JSON serializer on the producer side (never hand-roll Any JSON)","Use lowercase 'value' exactly, per the protobuf JSON mapping","Add round-trip tests: serialize with the producer, deserialize with this parser"],"tags":["protobuf","json-parsing","any-well-known-type"],"backgroundTag":"protobuf-unmarshal-failed","analyzedSha":"016f98412ea5e11756b286736f479b66ab6216d5","analyzedAt":"2026-09-12T01:08:58.711Z","contentChangedAt":"2026-09-12T01:08:58.711Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}