-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUGFIX: Add support for nested definitions in Python mcap-protobuf-su…
…pport (#1321) ### Changelog Bugfix: Support nested message definitions in mcap-protobuf-support ### Description Consider the following Protobuf definition: ``` message NestedTypeMessage { message NestedType { string data = 1; } NestedType nested = 1; } ``` Currently the decoder's use of the `protobuf.GetMessageClassesForFiles()` misses out the inner `NestedType` definition, causing decoding failures from missing nested descriptors, even though those descriptors would have been populated as part of the encoded file descriptors in an MCAP file. The error that is raised is something like: `FileDescriptorSet for type {schema.name} is missing that schema` This issue persists to an arbitrary level of nesting. This PR fixes that issue (including for deeply nested definitions) and adds a unit test to prevent regression. ### PS: How soon after merging this will it make it to PyPI? Signed-off-by: methylDragon <methylDragon@gmail.com>
- Loading branch information
1 parent
fb2b5f2
commit 2a13425
Showing
5 changed files
with
99 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
python/mcap-protobuf-support/tests/proto/test_proto/nested_type_message.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
syntax = "proto3"; | ||
|
||
|
||
package test_proto; | ||
|
||
message NestedTypeMessage { | ||
message NestedType1 { | ||
message DoublyNestedType { | ||
string data = 1; | ||
} | ||
|
||
DoublyNestedType doubly_nested_type_message = 1; | ||
} | ||
|
||
message NestedType2 { | ||
string data = 1; | ||
} | ||
|
||
NestedType1 nested_type_message_1 = 1; | ||
NestedType2 nested_type_message_2 = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
python/mcap-protobuf-support/tests/test_proto/nested_type_message_pb2.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.