[Protobuf][3/n] Wire an actor UUID validator into generated protobuf server code - #2520
Merged
mark200 merged 4 commits intoAug 27, 2026
Conversation
mark200
force-pushed
the
add-support-for-uuid-annotation-protobuf-wire-validator-in-server
branch
4 times, most recently
from
August 3, 2026 20:54
b2d55db to
f5b68cc
Compare
mark200
force-pushed
the
add-support-for-uuid-annotation-protobuf-wire-validator-in-server
branch
4 times, most recently
from
August 11, 2026 13:11
58d1b8f to
e76a7db
Compare
mark200
force-pushed
the
add-support-for-uuid-annotation-protobuf-wire-validator-in-server
branch
2 times, most recently
from
August 11, 2026 15:08
ebfd0b1 to
7908d25
Compare
CoolTomatos
previously approved these changes
Aug 13, 2026
mark200
force-pushed
the
add-support-for-uuid-annotation-protobuf-wire-validator-in-server
branch
from
August 17, 2026 13:50
7908d25 to
96852e6
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
mark200
dismissed
CoolTomatos’s stale review
August 17, 2026 19:50
The merge-base changed after approval.
mark200
force-pushed
the
add-support-for-uuid-annotation-protobuf-wire-validator-in-server
branch
from
August 17, 2026 19:50
96852e6 to
303fe72
Compare
Comment on lines
+237
to
+239
| // server template uses it to gate the service-wide handler struct's | ||
| // validator field and the validator extraction in the Build/Fx entry | ||
| // points. |
There was a problem hiding this comment.
I couldn't understand this explanation
Collaborator
Author
There was a problem hiding this comment.
Updated the comment
Comment on lines
+46
to
+48
| // registerConfig holds the settings a slice of RegisterOptions resolves | ||
| // to. It is threaded to generated server code via the option helpers | ||
| // below. |
There was a problem hiding this comment.
Sorry, I couldn't understand any of this :(
Collaborator
Author
There was a problem hiding this comment.
Updated the comment here as well
mark200
force-pushed
the
add-support-for-uuid-annotation-protobuf-wire-validator-in-server
branch
from
August 20, 2026 22:59
afc23d8 to
18502a6
Compare
mthakoreuber
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The previous PR#2519 in this stack makes protoc-gen-yarpc-go emit an
ActorUUID()accessor on every message with a reachableactor_uuid-annotated field. This PR closes the loop on the server side: it lets services install a validator that runs against those UUIDs after the request is decoded but before the user's handler executes, mirroring what thriftrw-plugin-yarpc already provides for thrift services (encoding/thrift.ActorUUIDValidator).New public API in
encoding/protobuf(actor_uuid.go):-
ActorUUIDValidator—func(ctx, actorUUIDs []string) error, receiving exactly what the generatedActorUUID()accessor returns.-
RegisterOption/WithActorUUIDValidator(v)— server-side registration option that installs the validator.-
ValidateActorUUID(...)andActorUUIDValidatorFromOptions(...)— helpers called by generated code, not by users. A rejection is wrapped in anPermissionDeniedYARPC errorGenerated code (template in
lib.go, fixture inwithuuid.pb.yarpc.go):-
Build<Service>YARPCProceduresgains a variadic...protobuf.RegisterOptionparameter, the handler struct carries the validator, and every handler whose request type has annotated paths (unary, oneway, and streaming handlers that carry a request message) calls
ValidateActorUUID(ctx, validator, request.ActorUUID(), service, method)before invoking the user's handler.- The Fx constructors accept the validator as an
optional:"true"dependency.Changed files
-
encoding/protobuf/actor_uuid.go— Public server-side API-
encoding/protobuf/protoc-gen-yarpc-go/internal/lib/lib.go— Template changes; conditionally add validator fields,RegisterOptionparams, and per-handlerValidateActorUUIDcalls only for annotated services/methods-
encoding/protobuf/protoc-gen-yarpc-go/internal/lib/uuid.go— Per file UUID analysis cache;serviceHasActorUUID/methodHasActorUUIDgating helpers; memoized walk results-
encoding/protobuf/protoc-gen-yarpc-go/internal/tests/withuuid/withuuid.pb.yarpc.go— Regenerated fixture showing validator plumbingBackwards compatibility
Installing no validator is always safe: a nil validator makes the generated check a no-op, so services that regenerate but never call
WithActorUUIDValidatorkeep their existing behaviour. Whether an empty UUID slice is acceptable is the validator's decision, so handlers on partially annotated services can still be supported by treating empty as "not provided".Stacked PRs
internal/protogen— shared descriptor-agnostic core PR#2535ActorUUID()emission in protoc-gen-yarpc-go PR#2519Test Plan
validator_test.goagainst the real generatedwithuuidfixture: validator receives the exact UUIDs the accessor collects, rejections surface asPermissionDeniederrors naming the service and procedure and never reach the handler, nil validator and unannotated methods skip validation entirely.RELEASE NOTES:
Wire ActorUUID validator into protobuf generated code