-
Notifications
You must be signed in to change notification settings - Fork 38
feat: migrate Resource APIs to Connect RPC #1174
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
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pull Request Test Coverage Report for Build 18274242710Details
💛 - Coveralls |
8ed4fba
to
404236f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates all 6 Resource management APIs from traditional gRPC to the modern Connect RPC framework, following established migration patterns from previous API conversions. The migration includes comprehensive test coverage with 37 test cases and maintains all original functionality including error handling, audit logging, and business logic.
- Converts all Resource API handlers to use Connect RPC request/response patterns with proper error mapping
- Migrates comprehensive test suites with enhanced coverage for all error and success scenarios
- Adds specific
ErrResourceNotFound
error constant for better error specificity
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
internal/api/v1beta1connect/resource.go |
Implements 5 new Connect RPC handlers (ListProjectResources, CreateProjectResource, GetProjectResource, UpdateProjectResource, DeleteProjectResource) |
internal/api/v1beta1connect/resource_test.go |
Adds comprehensive test suites for all new Connect RPC handlers with 31 new test cases |
internal/api/v1beta1connect/errors.go |
Adds ErrResourceNotFound constant for consistent error handling |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
2cc8b7c
to
758c569
Compare
758c569
to
3e6cd09
Compare
Resource APIs Migration to Connect RPC
This PR migrates all Resource management APIs from gRPC to Connect RPC framework, following the established patterns from previous API migrations.
Migration Overview
Converting Resource 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 (6/6) - COMPLETE
ListResources
internal/api/v1beta1connect/resource.go:18-41
ListProjectResources
internal/api/v1beta1connect/resource.go:43-64
CreateProjectResource
internal/api/v1beta1connect/resource.go:66-125
GetProjectResource
internal/api/v1beta1connect/resource.go:127-148
UpdateProjectResource
internal/api/v1beta1connect/resource.go:150-210
DeleteProjectResource
internal/api/v1beta1connect/resource.go:212-240
🎉 All Resource APIs have been successfully migrated to Connect RPC!
Technical Changes
API Implementation Updates
*connect.Request[frontierv1beta1.RequestType]
(*connect.Response[frontierv1beta1.ResponseType], error)
request.GetField()
torequest.Msg.GetField()
connect.NewResponse()
Test Migration
Error Handling
connect.NewError(connect.CodeInternal, ErrInternalServerError)
connect.NewError(connect.CodeInvalidArgument, ErrBadRequest)
connect.NewError(connect.CodeAlreadyExists, ErrConflictRequest)
connect.NewError(connect.CodeUnauthenticated, ErrUnauthenticated)
connect.NewError(connect.CodeNotFound, ErrResourceNotFound)
ErrResourceNotFound
constant for better error specificityKey Implementation Details
ListResources
schema.ParseNamespaceAliasIfRequired()
for namespace handlingresource.Filter
with namespace and project IDtransformResourceToPB()
DeleteProjectResource
resource.ErrNotExist
,resource.ErrInvalidUUID
,resource.ErrInvalidID
→ NotFoundUpdateProjectResource
resource.ErrNotExist
,resource.ErrInvalidUUID
,resource.ErrInvalidID
→ NotFoundresource.ErrInvalidDetail
,resource.ErrInvalidURN
→ BadRequestresource.ErrConflict
→ AlreadyExists (conflict)GetProjectResource
resource.ErrNotExist
→ Not Foundresource.ErrInvalidUUID
→ Not Foundresource.ErrInvalidID
→ Not FoundCreateProjectResource
Verification
Each migrated API goes through:
make build
)make test
)make lint
)Final test coverage: 54.2% for v1beta1connect package (37 total test cases)
Files Modified
Implementation Files
internal/api/v1beta1connect/resource.go
- Connect RPC resource handlersinternal/api/v1beta1connect/resource_test.go
- Connect RPC resource testsSupporting Files
internal/api/v1beta1connect/errors.go
- AddedErrResourceNotFound
internal/api/v1beta1connect/metaschema.go
Migration Methodology
Following established systematic approach:
Summary
✅ Migration Complete: All 6 Resource APIs successfully migrated to Connect RPC
✅ Test Coverage: 37 comprehensive test cases covering all scenarios
✅ Error Handling: Consistent Connect RPC error patterns
✅ Audit Logging: Preserved for create/update/delete operations
✅ Business Logic: All original functionality maintained
✅ Quality: Passes build, test, and lint verification
This completes the Resource APIs migration milestone. All Resource management endpoints now use the modern Connect RPC framework with improved type safety, better error handling, and comprehensive test coverage.