Skip to content

feat!: Migrate from jhump/protoreflect to google.golang.org/protobuf#1513

Merged
quirogas merged 113 commits into
v2from
feat-migrate-to-protobuf-go
Aug 27, 2025
Merged

feat!: Migrate from jhump/protoreflect to google.golang.org/protobuf#1513
quirogas merged 113 commits into
v2from
feat-migrate-to-protobuf-go

Conversation

@quirogas

@quirogas quirogas commented Jul 31, 2025

Copy link
Copy Markdown
Contributor

Migrate from jhump/protoreflect to google.golang.org/protobuf

This pull request executes a large-scale migration of the entire codebase from the third-party jhump/protoreflect library to the official google.golang.org/protobuf library and its associated APIs (protoreflect, protocompile*, etc.).

The primary goal of this change is 100% functional equivalence. This PR is intended as a pure dependency swap with no intentional behavioral changes.

Note: in the case of protocompile the migration was to it successor bufbuild/protocompile

Key Changes:

  • Dependency Swap: All imports and usages of github.com/jhump/protoreflect have been removed and replaced with google.golang.org/protobuf. The go.mod and go.sum files have been updated accordingly.
  • API Usage Update: The codebase has been updated to use the modern protoreflect interfaces for descriptor traversal, option access, and type handling.
  • Test Infrastructure: The test suite's proto parsing logic has been migrated from jhump/protoparse to bufbuild/protocompile, which is the recommended tool for working with the new protoreflect library. This is consolidated in the rules/internal/testutils/compile.go file (this is to keep the test logic relatively similar).

BREAKING CHANGE:

The public API of the linter rules has changed. Any functions or rule definitions that previously exposed types from the jhump/protoreflect library (e.g., desc.MessageDescriptor, desc.FieldDescriptor) now expose the official protoreflect.MessageDescriptor, protoreflect.FieldDescriptor, etc. types from google.golang.org/protobuf.

Consumers who use the api-linter as a library and have written custom rules will need to update their code to use the new protoreflect types.

For Reviewers:

This is a large but highly mechanical change. The vast majority of diffs are simple type and method name replacements.

When reviewing, please focus on:

  1. Functional Equivalence: The most critical task is to spot any potential logic drift. The changes should be a 1:1 mapping of the old API calls to the new ones.
  2. Test Scrutiny: The tests are our primary defense against regressions. While CI is passing, it's important to ensure that tests were not inadvertently weakened during the migration.
  3. Consistency: Ensure the migration has been applied consistently across the entire codebase.

Given the size of the PR, it may be helpful to review directory-by-directory, starting with lint/, then locations/, then rules/internal, then rules/, then cmd/ (helps put everything together as changes the previous are dependencies to the other).

@quirogas quirogas self-assigned this Jul 31, 2025
@quirogas quirogas added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jul 31, 2025
@quirogas
quirogas marked this pull request as ready for review August 27, 2025 07:41
@quirogas
quirogas requested review from a team and noahdietz August 27, 2025 07:41
Comment thread internal/version.go Outdated
@quirogas quirogas added v2 and removed do not merge Indicates a pull request not ready for merge, due to either quality or timing. labels Aug 27, 2025
@quirogas
quirogas merged commit 0df18d2 into v2 Aug 27, 2025
6 checks passed
@quirogas
quirogas deleted the feat-migrate-to-protobuf-go branch August 27, 2025 16:46
quirogas added a commit that referenced this pull request Oct 22, 2025
…1554)

* feat!: Migrate from jhump/protoreflect to google.golang.org/protobuf (#1513)

This commit migrates the entire codebase from the `jhump/protoreflect` and deprecated `github.com/golang/protobuf` libraries to the new `google.golang.org/protobuf` library. This is a significant change that modernizes the codebase and improves performance and maintainability.

BREAKING CHANGE: This migration introduces breaking changes to the public API. Users will need to update their code to use the new `google.golang.org/protobuf` types.
--- 
## Extended description

*   feat!(lint): migrate to protobuf-go
*   feat!(locations): migrate to protobuf-go
*   feat!(internal): migrate to protobuf-go
*   feat!(rules): migrate AIPs from protoreflect to protobuf-go
*   feat!(cli): migrate to protobuf-go

Co-authored-by: Noah Dietz <[email protected]>

---------

Co-authored-by: Noah Dietz <[email protected]>

* fix(cli): resolve linting errors related to incorrect positioning whe… (#1531)

* fix(cli): allow disabling all rules and then enabling a single rule, or multiple rules
* fix(cli): resolve linting errors related to incorrect positioning when working with descriptor sets without source info

* fix(cli): deduplicate descriptor sets on load (#1536)

* chore(v2): catch up with main (#1535)

* chore(v2): catch up with main

* chore(AIP-160): migrate recently added rules

* chore(rules/internal/utils): utilify extension parsing (#1537)

* chore(rules/internal/utils): utilify extension parsing

* chore: attempt using generics

* chore: change all to generic func

* chore: remove unused

* chore: use marshal/unmarshal instead of merge

* chore: export method add docs

* chore: clean up error modes

* chore(internal): add test util (#1538)

* chore(internal): add test util

* chore(internal): add helper mark

* chore(internal): bump version (#1542)

* fix(cli):  resolve import path resolution (#1545)

* fix(cli): fix import resolution

* chore(cli): fix integration test

* chore(cli): compile every proto file separatelly to avoid import and compilation collisions

* chore(cli): add integration test for thrid_party dir scenario

* chore(cli): simplify test

* chore(cli): expand comment

* chore(rules): allow AIP-157 View field in standard methods (#1548)

* feat(AIP-133): allow view field in create request

* feat(AIP-134): allow view field in update request

* feat(AIP-135): allow view field in delete request

* chore(rules): allow include _view suffixed fields

* docs(AIP-133): update docs for request-unknown-fields

* docs(AIP-134): update docs for request-unknown-fields

* docs(AIP-135): update docs for request-unknown-fields

* chore(rules): remove debug logic

* chore(v2): catch up with main (again) (#1549)

* fix(lint): linter config on windows (#1551)

* fix(lint): linter config on windows

* docs: update install command (#1553)

* chore: v2 catch up with main  (#1555)

Merge main into v2 before merging v2 into main

---------

Co-authored-by: Noah Dietz <[email protected]>
alethenorio added a commit to einride/sage that referenced this pull request Oct 30, 2025
This updates api-linter to version 2.0.0.

It is marked a breaking change in the repo but looking at the
[details](googleapis/api-linter#1513) for the
following reasons:

1. Any functions or rule definitions that previously exposed types from
   the jhump/protoreflect library (e.g., desc.MessageDescriptor,
   desc.FieldDescriptor) now expose the official
   protoreflect.MessageDescriptor, protoreflect.FieldDescriptor, etc.
   types from google.golang.org/protobuf.
2. Consumers who use the api-linter as a library and have written custom
   rules will need to update their code to use the new protoreflect
   types.

The first one feels like very niche and not a general concern at
Einride. The second is not a valid use case for Sage which is not used
as a library so this breaking change feels acceptable.
alethenorio added a commit to einride/sage that referenced this pull request Oct 30, 2025
This updates api-linter to version 2.0.0.

It is marked a breaking change in the repo but looking at the
[details](googleapis/api-linter#1513) for the
following reasons:

1. Any functions or rule definitions that previously exposed types from
   the jhump/protoreflect library (e.g., desc.MessageDescriptor,
   desc.FieldDescriptor) now expose the official
   protoreflect.MessageDescriptor, protoreflect.FieldDescriptor, etc.
   types from google.golang.org/protobuf.
2. Consumers who use the api-linter as a library and have written custom
   rules will need to update their code to use the new protoreflect
   types.

The first one feels like very niche and not a general concern at
Einride. The second is not a valid use case for Sage which is not used
as a library so this breaking change feels acceptable.

Also as per googleapis/api-linter#1545
api-linter can now correctly handle relative paths which solves some use
cases when proto files are spread across different places in a
repository so we switch to using relative paths to the buf.yaml rather
than aboslute.
alethenorio added a commit to einride/sage that referenced this pull request Oct 30, 2025
This updates api-linter to version 2.0.0.

It is marked a breaking change in the repo but looking at the
[details](googleapis/api-linter#1513) the
following reasons are stated:

1. Any functions or rule definitions that previously exposed types from
   the jhump/protoreflect library (e.g., desc.MessageDescriptor,
   desc.FieldDescriptor) now expose the official
   protoreflect.MessageDescriptor, protoreflect.FieldDescriptor, etc.
   types from google.golang.org/protobuf.
2. Consumers who use the api-linter as a library and have written custom
   rules will need to update their code to use the new protoreflect
   types.

The first one feels like very niche and not a general concern at
Einride. The second is not a valid use case for Sage which is not used
as a library so this breaking change feels acceptable.

Also as per googleapis/api-linter#1545
api-linter can now correctly handle relative paths which solves some use
cases when proto files are spread across different places in a
repository so we switch to using relative paths to the buf.yaml rather
than aboslute.
alethenorio added a commit to einride/sage that referenced this pull request Oct 31, 2025
This updates api-linter to version 2.0.0.

It is marked a breaking change in the repo but looking at the
[details](googleapis/api-linter#1513) the
following reasons are stated:

1. Any functions or rule definitions that previously exposed types from
   the jhump/protoreflect library (e.g., desc.MessageDescriptor,
   desc.FieldDescriptor) now expose the official
   protoreflect.MessageDescriptor, protoreflect.FieldDescriptor, etc.
   types from google.golang.org/protobuf.
2. Consumers who use the api-linter as a library and have written custom
   rules will need to update their code to use the new protoreflect
   types.

The first one feels like very niche and not a general concern at
Einride. The second is not a valid use case for Sage which is not used
as a library so this breaking change feels acceptable.

Also as per googleapis/api-linter#1545
api-linter can now correctly handle relative paths which solves some use
cases when proto files are spread across different places in a
repository so we switch to using relative paths to the buf.yaml rather
than aboslute.
alethenorio added a commit to einride/sage that referenced this pull request Oct 31, 2025
This updates api-linter to version 2.0.0.

It is marked a breaking change in the repo but looking at the
[details](googleapis/api-linter#1513) the
following reasons are stated:

1. Any functions or rule definitions that previously exposed types from
   the jhump/protoreflect library (e.g., desc.MessageDescriptor,
   desc.FieldDescriptor) now expose the official
   protoreflect.MessageDescriptor, protoreflect.FieldDescriptor, etc.
   types from google.golang.org/protobuf.
2. Consumers who use the api-linter as a library and have written custom
   rules will need to update their code to use the new protoreflect
   types.

The first one feels like very niche and not a general concern at
Einride. The second is not a valid use case for Sage which is not used
as a library so this breaking change feels acceptable.

Also as per googleapis/api-linter#1545
api-linter can now correctly handle relative paths which solves some use
cases when proto files are spread across different places in a
repository so we switch to using relative paths to the buf.yaml rather
than aboslute.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants