-
Notifications
You must be signed in to change notification settings - Fork 40
feat: migrate Preferences APIs to Connect RPC #1179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pull Request Test Coverage Report for Build 18335446474Details
💛 - Coveralls |
whoAbhishekSah
approved these changes
Oct 8, 2025
40c8677 to
dab1e8a
Compare
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.
Preferences APIs Migration to Connect RPC
This PR migrates Preferences management APIs from gRPC to Connect RPC framework, following the established patterns from previous API migrations.
Migration Overview
Converting Preferences APIs from traditional gRPC handlers to buf Connect RPC handlers with proper error handling, request/response wrapping, and comprehensive test coverage.
APIs Migration Progress
✅ Completed APIs (7/X)
DescribePreferencesinternal/api/v1beta1connect/preferences.go:155-164CreateOrganizationPreferencesinternal/api/v1beta1connect/preferences.go:60-86ListOrganizationPreferencesinternal/api/v1beta1connect/preferences.go:91-106CreateUserPreferencesinternal/api/v1beta1connect/preferences.go:106-132ListUserPreferencesinternal/api/v1beta1connect/preferences.go:134-150CreateCurrentUserPreferencesinternal/api/v1beta1connect/preferences.go:161-194ListCurrentUserPreferencesinternal/api/v1beta1connect/preferences.go:196-220🔄 Remaining APIs
Technical Changes
API Implementation Updates
*connect.Request[frontierv1beta1.RequestType](*connect.Response[frontierv1beta1.ResponseType], error)request.GetField()torequest.Msg.GetField()connect.NewResponse()Test Migration
Key Implementation Details
ListCurrentUserPreferences
GetLoggedInPrincipalto get current user contextpreference.Filter{UserID: principal.ID}preference.ErrInvalidFilter→InvalidArgument(filter validation)InternalServerErrortransformPreferenceToPB()for each preferenceCreateCurrentUserPreferences
GetLoggedInPrincipalto get current user contextpreference.ErrTraitNotFound→InvalidArgument(trait validation)preference.ErrInvalidValue→InvalidArgument(value validation)InternalServerErrorResourceID: principal.IDandResourceType: schema.UserPrincipalListUserPreferences
preference.Filter{UserID: req.Msg.GetId()}preference.ErrInvalidFilter→InvalidArgument(filter validation)InternalServerErrortransformPreferenceToPB()for each preferenceCreateUserPreferences
ResourceID: req.Msg.GetId()andResourceType: schema.UserPrincipalpreference.ErrTraitNotFound→InvalidArgument(trait validation)InternalServerErrortransformPreferenceToPB()for response formattingListOrganizationPreferences
preference.Filter{OrgID: req.Msg.GetId()}preference.ErrInvalidFilter→InvalidArgument(filter validation)InternalServerErrortransformPreferenceToPB()for each preferenceCreateOrganizationPreferences
ResourceID: req.Msg.GetId()andResourceType: schema.OrganizationNamespacepreference.ErrTraitNotFound→InvalidArgument(trait validation failed)InternalServerErrortransformPreferenceToPB()for each created preferenceDescribePreferences
preferenceService.Describe(ctx)transformPreferenceTraitToPB()for each traitTraitInputText→PreferenceTrait_Text{}TraitInputSelect→PreferenceTrait_Select{}TraitInputCheckbox→PreferenceTrait_Checkbox{}Verification
Each migrated API goes through:
make build)make test)make lint)Current test coverage: Enhanced for v1beta1connect package (29 test cases total)
Files Modified
Implementation Files
internal/api/v1beta1connect/preferences.go- Added all seven Preferences Connect RPC handlersinternal/api/v1beta1connect/preferences_test.go- Comprehensive test suite with 29 test casesMigration Methodology
Following established systematic approach:
Enhanced Error Handling
The Connect RPC implementations provide improved error handling over the original gRPC handlers:
ErrInvalidFilter)ErrTraitNotFound)ErrInvalidValue)Next Steps