feat: implement CheckCurrentUserPATTitle RPC#1469
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a CheckCurrentUserPATTitle API and related IsTitleAvailable plumbing across service, repository, mocks, handler, proto/connect, validation, tests, and authorization skip-list; also updates a Makefile commit hash. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/api/v1beta1connect/user_pat_test.go (1)
924-1060: Add a test for request validation failure (CodeInvalidArgument).Current cases cover auth/service outcomes well, but not the
request.Msg.Validate()failure path. A dedicated case would lock in that mapping and ensureIsTitleAvailableis not called on invalid input.Suggested test case addition
+{ + name: "should return invalid argument when request validation fails", + setup: func(ps *mocks.UserPATService, as *mocks.AuthnService) { + as.EXPECT().GetPrincipal(mock.Anything).Return(authenticate.Principal{ + ID: testUserID, + Type: schema.UserPrincipal, + User: &user.User{ID: testUserID}, + }, nil) + }, + request: connect.NewRequest(&frontierv1beta1.CheckCurrentUserPATTitleRequest{ + OrgId: "", + Title: "", + }), + wantErr: connect.NewError(connect.CodeInvalidArgument, ErrBadRequest), +},
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1413893b-8722-42aa-975f-f7c091b01a6b
⛔ Files ignored due to path filters (1)
proto/v1beta1/frontier.pb.gois excluded by!**/*.pb.go
📒 Files selected for processing (13)
Makefilecore/userpat/mocks/repository.gocore/userpat/service.gocore/userpat/service_test.gocore/userpat/userpat.gointernal/api/v1beta1connect/interfaces.gointernal/api/v1beta1connect/mocks/user_pat_service.gointernal/api/v1beta1connect/user_pat.gointernal/api/v1beta1connect/user_pat_test.gointernal/store/postgres/userpat_repository.gopkg/server/connect_interceptors/authorization.goproto/v1beta1/frontier.pb.validate.goproto/v1beta1/frontierv1beta1connect/frontier.connect.go
Pull Request Test Coverage Report for Build 23426153594Details
💛 - Coveralls |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/store/postgres/userpat_repository.go (1)
229-250: Add repository tests for this SQL path.This changed DB path currently has no changed-line coverage in the report. Please add repository-level tests for: case-insensitive match, soft-deleted rows ignored, and strict user/org scoping.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cadaf91a-63b4-4b91-b270-a79c512408f6
📒 Files selected for processing (10)
core/userpat/mocks/repository.gocore/userpat/service.gocore/userpat/service_test.gocore/userpat/userpat.gointernal/api/v1beta1connect/interfaces.gointernal/api/v1beta1connect/mocks/user_pat_service.gointernal/api/v1beta1connect/user_pat.gointernal/api/v1beta1connect/user_pat_test.gointernal/store/postgres/userpat_repository.gopkg/server/connect_interceptors/authorization.go
✅ Files skipped from review due to trivial changes (2)
- core/userpat/userpat.go
- internal/api/v1beta1connect/mocks/user_pat_service.go
🚧 Files skipped from review as they are similar to previous changes (4)
- internal/api/v1beta1connect/interfaces.go
- internal/api/v1beta1connect/user_pat.go
- internal/api/v1beta1connect/user_pat_test.go
- pkg/server/connect_interceptors/authorization.go
Description:
Summary
CheckCurrentUserPATTitleRPC to check if a PAT title is available for the current user in a given orgLOWER()in PostgresChanges
CheckCurrentUserPATTitleRPC, request (org_id, title), response (available: bool)IsTitleAvailable—NOT EXISTSquery matching the partial unique index (user_id, org_id, title WHERE deleted_at IS NULL)IsTitleAvailable— disabled check + delegates to repocore/userpatto.mockery.yamlManual test verification