fix(requests): isolate playground requests by user - #2206
Conversation
Playground requests now retain their authenticated creator and project members can only query their own records. Project owners and users with system-level request access retain project audit visibility. - add an internal request creator field and project-user index - apply creator filtering to requests and usage logs - cover persistence and privacy isolation with regression tests
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe Request schema now stores an optional immutable creator user ID. Playground requests assign this ID from the authenticated user. Project request scopes use it to isolate Playground requests while preserving owner, system-scope, and permitted API request access. ChangesRequest creator isolation
Estimated code review effort: 4 (Complex) | ~45 minutes Mergeability Score: ⚪ Minimal · up to The change isolates Playground requests by user while preserving owner and system audit access. No actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant AuthenticatedUser
participant RequestService
participant EntRequest
participant ProjectScopeRule
AuthenticatedUser->>RequestService: Create Playground request
RequestService->>EntRequest: Persist user_id
AuthenticatedUser->>ProjectScopeRule: Read project requests
ProjectScopeRule->>EntRequest: Apply creator and API-key filters
EntRequest-->>ProjectScopeRule: Return matching requests
ProjectScopeRule-->>AuthenticatedUser: Return authorized results
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/server/biz/request.go`:
- Around line 227-231: Update the Playground branch around contexts.GetUser to
return an authentication error when no authenticated user is present, and only
create the request after assigning the authenticated user’s ID via
mut.SetUserID. Add a regression test covering a Playground request without a
user and assert the authentication error.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: cd6a27f5-2727-48a5-b537-2e313333bc81
📒 Files selected for processing (15)
internal/ent/entql.gointernal/ent/internal/schema.gointernal/ent/migrate/schema.gointernal/ent/mutation.gointernal/ent/request.gointernal/ent/request/request.gointernal/ent/request/where.gointernal/ent/request_create.gointernal/ent/request_update.gointernal/ent/runtime/runtime.gointernal/ent/schema/request.gointernal/scopes/rule_user_project_scope_requests.gointernal/scopes/rule_user_project_scope_requests_test.gointernal/server/biz/request.gointernal/server/biz/request_user_isolation_test.go
Add the missing docstring required by repository documentation coverage checks.
…quest-user-isolation # Conflicts: # internal/ent/internal/schema.go
|
@looplj 是不是可以合并这个了?准备合并的话我再把冲突改了,不然还需要一直改。 这个PR处理的问题就是playground所有人都可见的问题。应该自己只能看见自己的游乐场才对。 |
Summary
Tests
go test ./internal/scopes -count=1go test ./internal/server/biz -run 'TestRequestService(CreateRequestAssignsPlaygroundUser|CreateRequestExecutionPersistsReasoningEffort)' -count=1Summary by CodeRabbit
New Features
Tests