Coding Standards

gRPC & Protobuf Conventions

Foundational

gRPC services are defined by their .proto files. That schema is the contract between every client and server, and once other teams depend on it you can only change it in safe, additive ways. Design the proto with care, use the standard status codes and deadlines, and secure the transport. This is the concrete conventions reference that goes with the broader API & Contract Design guideline.

gRPC gives you a typed, fast, binary contract and generated client code in many languages. The cost is that the wire format depends on field numbers, not names, so a small change to a .proto file can quietly break every existing client. Treat the proto as a long-lived public contract from day one.

All the security rules still apply: authenticate and authorise every call, validate input on the server, never return too much data, and never leak internals (see Authentication & Authorization, Trust Boundaries). gRPC has no built-in auth, so identity travels in metadata and is checked by an interceptor.

Proto & schema design

Status codes & errors

Deadlines, streaming & limits

Safety & evolution

A service, end to end

Renumbered field, OK on error, no deadline message Customer { string name = 1; string ssn = 1; } // reused number 1
// server: return OK with { error: "not found" } in the body
// client: call with no deadline, no TLS

A reused field number corrupts the wire format for old clients, an OK hides a real failure, and a call with no deadline over plaintext can hang and leak data. Broken and unsafe.

Stable numbers, correct codes, bounded message Customer { string name = 1; reserved 2; reserved "ssn"; }
// server: return NOT_FOUND with google.rpc.Status details, no internals
// client: deadline set, TLS on, retry only if idempotent

Field numbers are stable and removed ones are reserved, the correct status code is returned with a safe detail shape, and every call is bounded by a deadline over TLS.

Self-review checklist

Why it matters: A gRPC service is its .proto file, and field numbers, not names, define the wire format. That makes gRPC fast and strongly typed, but it also means a careless change can silently break every client in production. Stable field numbers, correct status codes, deadlines on every call, secure transport, and server-side authorisation are what keep gRPC services fast, safe, and able to evolve without breaking the teams that depend on them.