Skip to content

protoc-gen-buffa: expose custom bytes, string and repeated types - #824

Open
vanderbr wants to merge 1 commit into
anthropics:mainfrom
reallyme:plugin-custom-types
Open

vanderbr wants to merge 1 commit into
anthropics:mainfrom
reallyme:plugin-custom-types

Conversation

@vanderbr

@vanderbr vanderbr commented Nov 13, 2026 •

Copy link
Copy Markdown

Part of #822.

protoc-gen-buffa can now select the custom owned bytes, string and repeated-field representations already available through buffa-build, so Buf workflows can use these types without editing generated sources.

Option Effect
bytes_type_custom_in=<proto_path>=<rust_type> Custom bytes representation for matching fields
string_type_custom_in=<proto_path>=<rust_type> Custom string representation for matching fields
repeated_type_custom_in=<proto_path>=<template> Custom collection; * is the element type

The options are repeatable and preserve the existing normalization, prefix matching and last-match-wins ordering. . selects every field. Malformed rules produce option-specific errors. Codegen rejects unsupported non-path representations such as _, (), arrays, references and impl Trait in the plugin response, while preserving valid qualified associated-type paths and parenthesized type paths. Whether the named type exists and implements the required traits remains a consumer compile-time check.

Unmatched-rule diagnostics now work for both front ends and distinguish extension-only matches from fields in files generated by another invocation. Tests cover imported files, package-less extensions and diagnostic precedence.

The guide documents when Buf needs strategy: all to avoid duplicate generated element-trait implementations: custom bytes used as repeated elements or map values with JSON or vtable reflection, and custom strings in those positions with vtable reflection. Per-directory generation does not coordinate these implementations; this PR documents the supported single-invocation setup.

Validation:

  • Full workspace tests with all features.
  • Workspace Clippy with all targets and features, warnings denied; formatting and Markdown lint.
  • Real generated-crate compilation and binary round trips for qualified and nested parenthesized custom bytes, string and collection paths; CI runs this regression explicitly.
  • Rust 1.75 compilation of the affected packages using a temporary compatible lockfile. The repository MSRV, development toolchain, dependency constraints and lockfile are unchanged.
  • Regenerated well-known and option types with no checked-in output changes.

Contributed by ReallyMe Technologies Limited.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@vanderbr

Copy link
Copy Markdown
Author

recheck

Expose custom bytes, string and repeated-field rules through the plugin. Validate representation paths without rejecting qualified associated types or parentheses, clarify unmatched extension rules and single-invocation requirements, and compile-test preserved configurations in CI.
@vanderbr
vanderbr force-pushed the plugin-custom-types branch from 5c5074f to de1667d Compare November 17, 2026 14:04

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant