▲ | iamdelirium 7 days ago | ||||||||||||||||
You think you do but you really don't. What happens if you mark a field as required and then you need to delete it in the future? You can't because if someone stored that proto somewhere and is no longer seeing the field, you just broke their code. | |||||||||||||||||
▲ | thinkharderdev 7 days ago | parent | next [-] | ||||||||||||||||
If you need to deserialize an old version then it's not a problem. The unknown field is just ignored during deserialization. The problem is adding a required field since some clients might be sending the old value during the rollout. But in some situations you can be pretty confident that a field will be required always. And if you turn out to be wrong then it's not a huge deal. You add the new field as optional first (with all upgraded clients setting the value) and then once that is rolled out you make it required. And if a field is in fact semantically required (like the API cannot process a request without the data in a field) then making it optional at the interface level doesn't really solve anything. The message will get deserialized but if the field is not set it's just an immediate error which doesn't seem much worse to me than a deserialization error. | |||||||||||||||||
| |||||||||||||||||
▲ | ozgrakkurt 7 days ago | parent | prev [-] | ||||||||||||||||
Maybe you don’t delete it then? | |||||||||||||||||
|