Comment by hedora

3 days ago

Everytime someone proposes protobuf as an rpc format, I respond “Hell no! There’s no support for protocol versioning.”

Of course, I bring this up because they could just version their API keys, completely solving this problem and preventing future ones like it.

Versioning data formats is wrongthink over there, so I’m guessing they just… won’t.

Does JSON have support for protocol versioning?

  • Yep: JSON schema Alternatively, with typescript you can write:

    export type FooRpcV1 : { version: 1, ... } export type FooRpcV2 : { version: 2, ... }

    in zod syntax, and it'll do the right thing statically and at runtime (ask an LLM for help with the syntax).

    With protobufs (specifically protoc), you get some type like:

    export type FooRpc : { version : 1 | 2, v1fieldA? : string, v1fieldB? : int, v2fieldB? : string, v2fieldB? string };

    which is 2^5 message types, even if all fields of both versions were mandatory. Then application logic needs to validate it.