Skip to content

feat(protogen, BREAKING!): support protobuf editions and properly quote file option values#370

Open
Kybxd wants to merge 2 commits intomasterfrom
support-editions
Open

feat(protogen, BREAKING!): support protobuf editions and properly quote file option values#370
Kybxd wants to merge 2 commits intomasterfrom
support-editions

Conversation

@Kybxd
Copy link
Copy Markdown
Collaborator

@Kybxd Kybxd commented Mar 23, 2026

Summary

This MR adds support for Protobuf Editions in proto file generation, and changes how file-level option values are specified to give users full control over quoting.

Changes

Support protobuf edition

  • Added Edition field to ProtoOutputOption, allowing users to specify a protobuf edition (e.g., "2023", "2024").
  • When Edition is set, the generated .proto files emit edition = "20XX"; instead of syntax = "proto3";.
  • This enables the use of edition-specific features such as features.utf8_validation (edition 2023) and features.(pb.go).strip_enum_prefix (edition 2024).

File option value quoting change (BREAKING CHANGE)

  • File option values are now written as-is to the generated proto file (i.e., option <key= <value>;).
  • Users must explicitly include quotes in the value when needed. For example, go_package should now be specified as '"github.com/example/pkg"' instead of github.com/example/pkg.
  • This change is necessary to support edition features options (e.g., features.utf8_validation = NONE) which require unquoted enum values.

Tests

  • Added Test_bookExporter_export with table-driven test cases covering:
    • Default proto3 syntax mode
    • edition = "2023" with features.utf8_validation
    • edition = "2024" with features.(pb.go).strip_enum_prefix
  • Each test verifies the generated proto file contains the correct edition/syntax declaration and properly formatted options.

Migration Guide

Existing users must update their fileOptions configuration to include explicit quotes around string option values. For example:

# Before
fileOptions:
  go_package: github.com/example/protoconf

# After
fileOptions:
  go_package: '"github.com/example/protoconf"'

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.93%. Comparing base (bc70718) to head (cccbb1c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #370      +/-   ##
==========================================
+ Coverage   73.91%   73.93%   +0.01%     
==========================================
  Files          87       87              
  Lines        8664     8670       +6     
==========================================
+ Hits         6404     6410       +6     
  Misses       1700     1700              
  Partials      560      560              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

protogen(Protobuf-Editions): support Protobuf Edition 2023 and 2024

1 participant