Title: fix(custom-blocks): dedupe redundant workspace lookup in POST admin check by waleedlatif1 · Pull Request #5429 · simstudioai/sim · GitHub
Open Graph Title: fix(custom-blocks): dedupe redundant workspace lookup in POST admin check by waleedlatif1 · Pull Request #5429 · simstudioai/sim
X Title: fix(custom-blocks): dedupe redundant workspace lookup in POST admin check by waleedlatif1 · Pull Request #5429 · simstudioai/sim
Description: Summary Found while auditing for the same pattern fixed in #5426: the POST /api/custom-blocks handler called hasWorkspaceAdminAccess(userId, workspaceId) then separately called getWorkspaceWithOwner(workspaceId) again just to read organizationId — two independent DB fetches of the same workspace row for the same request Consolidated into a single checkWorkspaceAccess call, matching the exact pattern the GET handler in this same file already uses a few lines above access.canAdmin is logically identical to hasWorkspaceAdminAccess()'s result — verified against PERMISSION_RANK/permissionSatisfies in @sim/platform-authz/workspace: admin is the top rank (3), so permissionSatisfies(p, 'admin') can only be true when p === 'admin', same as the old check Same error responses, same status codes, same order of checks (admin check still runs before the organization-membership check) — zero behavior change, one fewer DB round-trip per publish request Type of Change Refactor / minor perf Testing bunx tsc --noEmit clean bunx biome check clean bun run check:react-query passes No existing test file for this route (none broken); logic equivalence verified analytically against the permission-rank system 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 Found while auditing for the same pattern fixed in #5426: the POST /api/custom-blocks handler called hasWorkspaceAdminAccess(userId, workspaceId) then separately called getWorkspaceWithOwn...
X Description: Summary Found while auditing for the same pattern fixed in #5426: the POST /api/custom-blocks handler called hasWorkspaceAdminAccess(userId, workspaceId) then separately called getWorkspaceWithOwn...
Opengraph URL: https://github.com/simstudioai/sim/pull/5429
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:10f54427-f06d-4bb1-d77b-4db5fd6abc49 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C720:2FE5F3:1EEEDD:2B6AB1:6AFB501C |
| html-safe-nonce | 53042ec50ab75807e7cb1490b0823f9a081e1e5fa6e8b77275323726cdeff1ae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzIwOjJGRTVGMzoxRUVFREQ6MkI2QUIxOjZBRkI1MDFDIiwidmlzaXRvcl9pZCI6IjQwNzc2NzY2MjE1OTMyNjgyNTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 100ef0e2211b3e5a73c88c4cb6b93477e3cefb8e336b83d509b12da68ec31a4e |
| hovercard-subject-tag | pull_request:3994327695 |
| 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/5429/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 Found while auditing for the same pattern fixed in #5426: the POST /api/custom-blocks handler called hasWorkspaceAdminAccess(userId, workspaceId) then separately called getWorkspaceWithOwn... |
| 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 |
| 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