Skip to content

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

Merged
wenchy merged 2 commits intomasterfrom
support-editions
Apr 2, 2026
Merged

protogen(BREAKING!): support protobuf editions and properly quote file option values#370
wenchy merged 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).
⚠️ Report is 1 commits behind head on master.

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.

@wenchy wenchy changed the title feat(protogen, BREAKING!): support protobuf editions and properly quote file option values protogen(BREAKING!): support protobuf editions and properly quote file option values Apr 2, 2026
Copy link
Copy Markdown
Member

@wenchy wenchy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wenchy wenchy merged commit 9ffe4ca into master Apr 2, 2026
11 checks passed
@wenchy wenchy deleted the support-editions branch April 2, 2026 07:54
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

2 participants