I'm trying to implement data contract logic.
I've 2 services switching messages with each other.
Service A send messages in some format + the file descriptor proto of the .proto file used to generate it. Service B gets them both, the message and the file descriptor proto and has to ensure the message doesn't break the schema defenition.
What I've did until now is to create a dynamic message instance using the descriptor proto and tried to unmarshal the message into the dynamic message instance, and in case no error occurred during the unmarshal process it counts as a success (message doesn't break the schema).
1. Is it ok to rely on the unmarshal function in order to decide whether the message is ok?
2. I noticed that even in case I'm sending messages with totally different schemas the unmarshal succeed. the only way I found to cause the unmarshal to fail is by sending proto2 messages with missing required fields.
So is it by design that every message can be unmarshled using a totally different schema definition?