{"action":"opened","issue":{"url":"https://api.github.com/repos/golang/protobuf/issues/689","repository_url":"https://api.github.com/repos/golang/protobuf","labels_url":"https://api.github.com/repos/golang/protobuf/issues/689/labels{/name}","comments_url":"https://api.github.com/repos/golang/protobuf/issues/689/comments","events_url":"https://api.github.com/repos/golang/protobuf/issues/689/events","html_url":"https://github.com/golang/protobuf/issues/689","id":353813008,"node_id":"MDU6SXNzdWUzNTM4MTMwMDg=","number":689,"title":"Incorrect size of encoded repeated fields","user":{"login":"gudvinr","id":1712806,"node_id":"MDQ6VXNlcjE3MTI4MDY=","avatar_url":"https://avatars3.githubusercontent.com/u/1712806?v=4","gravatar_id":"","url":"https://api.github.com/users/gudvinr","html_url":"https://github.com/gudvinr","followers_url":"https://api.github.com/users/gudvinr/followers","following_url":"https://api.github.com/users/gudvinr/following{/other_user}","gists_url":"https://api.github.com/users/gudvinr/gists{/gist_id}","starred_url":"https://api.github.com/users/gudvinr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gudvinr/subscriptions","organizations_url":"https://api.github.com/users/gudvinr/orgs","repos_url":"https://api.github.com/users/gudvinr/repos","events_url":"https://api.github.com/users/gudvinr/events{/privacy}","received_events_url":"https://api.github.com/users/gudvinr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-24T14:45:18Z","updated_at":"2018-08-24T14:45:18Z","closed_at":null,"author_association":"NONE","body":"**What version of protobuf and what language are you using?**\r\nVersion: b27b920\r\n\r\n**What did you do?**\r\nUnfortunately I can't provide code to reproduce behavior because it's statistically hard to catch an error.\r\n\r\nI have such message structure:\r\n```proto\r\nmessage MsgKey {\r\n\trequired uint32 key_1 = 1;\r\n\trequired uint32 key_2 = 2;\r\n}\r\n\r\nmessage SomeOtherInfo {\r\n\trequired uint32 id    = 1;\r\n\trepeated int64 arr_1  = 2 [packed = true];\r\n\trepeated uint32 arr_2 = 3 [packed = true];\r\n}\r\n\r\nmessage Payload {\r\n\trequired sint32 val_1 = 1;\r\n\toptional sint32 val_2 = 2 [default = 0];\r\n\toptional uint32 id    = 3;\r\n}\r\n\r\nmessage Info {\r\n\tmessage SubMsg {\r\n\t\trequired MsgKey key         = 1;\r\n\t\trepeated SomeOtherInfo info = 2;\r\n\t}\r\n\r\n\trequired uint64 id       = 1;\r\n\trepeated Payload payload = 2;\r\n\trepeated SubMsg msgs     = 3;\r\n}\r\n\r\nmessage RootMessage {\r\n\trepeated Info info = 1;\r\n};\r\n```\r\n\r\nAnd **sometimes** I'm getting incorrectly marshaled `RootMessage` in a way that it _seems_ to be packed correctly but puts wrong size to its header.\r\n\r\nExample of payload that encoded wrong:\r\n```\r\n0A750805120408001801120508D0031802120508C8011803120508D0031804120408321805120408281806120408781807120408001808120508D00518091204084E180A1204083A180B12040840180C12040800180D12040800180E12040800180F120508C8011810120408541811120408001812\r\n```\r\n\r\nAs you can see from the header its body lenght is `0x75` (or 117) but if you try to feed that message to `protoc --decode_raw` without schema you'll get an error:\r\n```\r\n$ echo -ne '<hex_message_content>' | xxd -r -p - | protoc --decode_raw\r\nFailed to parse input.\r\n```\r\n\r\nBut when I change length in header manually to `0x73` (115 which is correct size) it becomes readable:\r\n<details><summary><b>Click to expand</b></summary>\r\n<p>\r\n\r\n```\r\n1 {\r\n  1: 5\r\n  2 {\r\n    1: 0\r\n    3: 1\r\n  }\r\n  2 {\r\n    1: 464\r\n    3: 2\r\n  }\r\n  2 {\r\n    1: 200\r\n    3: 3\r\n  }\r\n  2 {\r\n    1: 464\r\n    3: 4\r\n  }\r\n  2 {\r\n    1: 50\r\n    3: 5\r\n  }\r\n  2 {\r\n    1: 40\r\n    3: 6\r\n  }\r\n  2 {\r\n    1: 120\r\n    3: 7\r\n  }\r\n  2 {\r\n    1: 0\r\n    3: 8\r\n  }\r\n  2 {\r\n    1: 720\r\n    3: 9\r\n  }\r\n  2 {\r\n    1: 78\r\n    3: 10\r\n  }\r\n  2 {\r\n    1: 58\r\n    3: 11\r\n  }\r\n  2 {\r\n    1: 64\r\n    3: 12\r\n  }\r\n  2 {\r\n    1: 0\r\n    3: 13\r\n  }\r\n  2 {\r\n    1: 0\r\n    3: 14\r\n  }\r\n  2 {\r\n    1: 0\r\n    3: 15\r\n  }\r\n  2 {\r\n    1: 200\r\n    3: 16\r\n  }\r\n  2 {\r\n    1: 84\r\n    3: 17\r\n  }\r\n  2 {\r\n    1: 0\r\n    3: 18\r\n  }\r\n}\r\n```\r\n</p></details>\r\n\r\nAnd there's an example of data of same message that encoded correctly:\r\n```\r\n0A730801120408001801120508D0031802120508C8011803120508D0031804120408001805120408001806120408781807120408001808120508D00518091204084E180A1204083A180B12040840180C12040800180D12040800180E12040800180F120508C8011810120408001811120408001812\r\n```"}}
{"actor":{"display_login":"gudvinr"}}