Repository navigation
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
recheck |
vanderbr
force-pushed
the
json-policy-codegen
branch
from
November 17, 2026 17:19
237d13e to
f21d03c
Compare
Route selected custom representations through their runtime JSON policies across owned and borrowed field shapes. Include bounded decode-hook and runtime-policy prerequisites with their current frame-context and fixed-diagnostic corrections. Preserve canonical type matching, provider reuse and reflection warnings.
vanderbr
force-pushed
the
json-policy-codegen
branch
from
November 18, 2026 23:27
f21d03c to
ba057b2
Compare
This branch has not been deployed
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.
Custom
bytesandstringrepresentations can opt into theirProtoBytesJson/ProtoStringJsonpolicies throughCodeGenConfig::json_policy_types,buffa_build::Config::json_policy_type(path), and the repeatable plugin optionjson_policy_type=<rust_type>. Unlisted representations retain their existing JSON behavior.Part of #822. Depends on #823, #824, #825 and #828; their reviewed changes are included in this branch until they merge. The branch is consolidated into one commit against
main.The generated routing covers singular, optional, repeated and oneof fields, map keys and values, and eager, lazy and owned views. Repeated and map fields use the runtime policy helpers without generating per-run
ProtoElemJsonimplementations for policy representations. Policy types can therefore live in a separate provider crate and be reused by independently generated consumer modules.Configuration fails closed for unmatched bindings and near-miss type names, including when JSON generation is disabled. Matching uses the configured rules so per-directory generation works. Policy string keys on enum-valued maps remain rejected until the enum map helpers support them. Equivalent path syntax is normalized for policy matching and generated trait deduplication, including whitespace, redundant type-path parentheses, optional raw identifiers and type-path turbofish; Rust aliases are not resolved.
CodeGenWarning::JsonPolicyReflectionBypass { policy_types }is emitted once when generated JSON fields actually use policies and reflection is enabled. It identifies the selected types. Reflective export/import, binary encoding and text formatting do not enforce JSON policies; policy refusal is not a confidentiality boundary. Unused policy configuration does not trigger this warning.The included parent hardening preserves plugin capabilities in error responses, accepts supported associated type paths, bounds custom decode hooks to their enclosing frames, and keeps map-key policy errors free of rejected input. The guarded-field guide explains policy scope, representation-owned scratch storage, cleanup responsibilities and reflection behavior.
The included decode-hook and runtime-policy implementations record frame context before handwritten decoder overrides and keep caller-buffer base64 errors free of input symbols and offsets. These corrections preserve policy selection, accepted base64, caller storage ownership and generated routing.
Validation:
The external protobuf conformance suite was not rerun for this follow-up.
Contributed by ReallyMe Technologies Limited.