-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
breaking: Issue-112 Fix Default Nested Protobuf Types #113
breaking: Issue-112 Fix Default Nested Protobuf Types #113
Conversation
if (reflection instanceof Namespace && reflection.nested) | ||
|
||
// Traverse down the nested Namespaces until we find a message Type instance (which extends Namespace) | ||
if (reflection instanceof Namespace && !(reflection instanceof Type) && reflection.nested) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open Question: Is it enough to just check that it's not a Type and has a nested object?
if(!(reflection instanceof Type) && reflection.nested)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried the patch as per @MikeDalby and it helped me for a nested ProtoBuf. Went from
decodedValue: MealItems { itemName: 'pizza' }
to a much better
decodedValue: Meal {
item: [],
drink: [ [DrinkItems], [DrinkItems] ],
name: 'pizza'
}
Producer was this Python snippet:
mybeer = meal_pb2.Meal.DrinkItems(drink_name="beer")
mywine = meal_pb2.Meal.DrinkItems(drink_name="wine")
meal = meal_pb2.Meal(name='pizza', drink=[mybeer,mywine])
# Less meal (for testing kafkajs which seems to miss the drinks
#meal = meal_pb2.Meal(name='pizza', drink=[])
producer.produce(topic=topic, key=str(uuid4()), value=meal)
While I'm missing the "beer" and "wine", at least I got drinks now.
Let's test that this works as intended. There's a test file called something like |
@Nevon I've added some tests based on the existing ones. Feel free to let me know if there's anything else you'd like to see here. |
Excellent! Thanks for the contribution. One thing that would be really helpful is if you could provide a short summary of how this change affects Protobuf users and what they need to do in order to maintain backwards compatibility (I guess explicitly provide a message type?), so I can add that in the release notes. |
@Nevon How does something like this sound: When creating an instance of If you were relying on this behavior may need to either:
See Issue #112 for more info |
@Nevon Just curious what the release process looks like / if there's a release schedule. Thanks! |
@Nevon Is there anything I can do to help get a release published? |
I've just had a lot going on both professionally and personally, so I haven't gotten around to it. Managed to get v3.0.0 out just now. Sorry about the delay. |
@Nevon I totally understand and sorry for pestering you. Thank you for all of your hard work! |
Fixes #112
This change accounts for the fact that the protobufjs
Type
class extends theNamespace
class. When traversing down the Namespaces we should stop on the first message Type instance, not just the first Namespace without an inner/nested Namespace.