Title: refactor(permissions): make hasWorkspaceAdminAccess and getUserEntityPermissions thin wrappers of checkWorkspaceAccess by waleedlatif1 · Pull Request #5430 · simstudioai/sim · GitHub
Open Graph Title: refactor(permissions): make hasWorkspaceAdminAccess and getUserEntityPermissions thin wrappers of checkWorkspaceAccess by waleedlatif1 · Pull Request #5430 · simstudioai/sim
X Title: refactor(permissions): make hasWorkspaceAdminAccess and getUserEntityPermissions thin wrappers of checkWorkspaceAccess by waleedlatif1 · Pull Request #5430 · simstudioai/sim
Description: Summary Follow-up to #5429 (custom-blocks dedup fix): the root cause of that bug was that hasWorkspaceAdminAccess and getUserEntityPermissions('workspace', ...) each independently re-implement the same getWorkspaceWithOwner + getEffectiveWorkspacePermission fetch that checkWorkspaceAccess already does. Any call site that uses two of these three functions for the same (userId, workspaceId) pair silently pays for redundant DB round-trips, and worse, the three implementations could drift apart over time Consolidated: hasWorkspaceAdminAccess and getUserEntityPermissions's workspace branch are now thin wrappers around checkWorkspaceAccess — matching the pattern assertActiveWorkspaceAccess already used in this same file Added permission: PermissionType | null to the WorkspaceAccess return shape so getUserEntityPermissions doesn't need its own second getEffectiveWorkspacePermission call to get the raw value Zero behavior change: canAdmin is exactly permission === 'admin' (verified against PERMISSION_RANK — admin is the top rank, nothing else satisfies it) Type of Change Refactor / code quality Testing bunx tsc --noEmit clean, bunx biome check clean 616 existing tests across lib/workspaces, lib/credentials, lib/invitations, lib/copilot/vfs, and the affected API routes pass unmodified 2 test assertions updated for the new additive permission field (exact-shape .toEqual() checks) Ran an independent security-focused review specifically checking argument-order correctness (checkWorkspaceAccess(workspaceId, userId) vs the wrapper functions' (userId, workspaceId) order) and privilege-escalation risk in the canAdmin delegation — no issues found Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
Open Graph Description: Summary Follow-up to #5429 (custom-blocks dedup fix): the root cause of that bug was that hasWorkspaceAdminAccess and getUserEntityPermissions('workspace', ...) each independently re-imple...
X Description: Summary Follow-up to #5429 (custom-blocks dedup fix): the root cause of that bug was that hasWorkspaceAdminAccess and getUserEntityPermissions('workspace', ...) each independently ...
Opengraph URL: https://github.com/simstudioai/sim/pull/5430
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:02574484-b1c8-2cd2-5bd1-a06837b572de |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C702:2550AC:1DE052:29DF0C:6AFB5018 |
| html-safe-nonce | c553aa2474b371460e1c971355be37973cf84f59ffe97a7d1ff9e7bf4e672b81 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzAyOjI1NTBBQzoxREUwNTI6MjlERjBDOjZBRkI1MDE4IiwidmlzaXRvcl9pZCI6IjcyMDAwMjI1MzE4NzEwMzU0MTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c2e0c245496db68eded864c57610381fb9bf007138f5c6593b76714758838dd9 |
| hovercard-subject-tag | pull_request:3994347420 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/5430/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary Follow-up to #5429 (custom-blocks dedup fix): the root cause of that bug was that hasWorkspaceAdminAccess and getUserEntityPermissions('workspace', ...) each independently re-imple... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cbf66c024bb6d10e6955baa7413c54cf13a201bb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width