fix(frontend): invalidate approval request queries at project scope#6135
Conversation
…equests by project
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
LGTM — mechanical React Query invalidation fix; the inline nit about dead envSlug/requestedBy params is non-blocking.
Extended reasoning...
Overview
This PR is a small, frontend-only cache-invalidation fix. It introduces two new broader React Query keys — secretApprovalRequestKeys.listAllForProject({ projectId }) and accessApprovalKeys.getAccessApprovalRequestsAllForProject(projectSlug) — which are strict prefixes of the existing narrower list keys. The new project-scoped keys are then invalidated from approval-request mutations, secret mutations (create/update/delete/batch/move/commit), ActionBar.handleSaveFolderImport, and SecretListView.handleSaveSecret/handleSecretDelete. The intent is to ensure that approval-request lists refresh regardless of which narrower filter key the UI had subscribed under.
Security risks
None meaningful. These are client-side React Query cache invalidations — no auth, crypto, permissions, or server-side logic is touched. Request bodies and API surfaces are unchanged. The prefix-based invalidation is wider than before but still scoped to the current project.
Level of scrutiny
Low. The changes are mechanical and repetitive: each modified callsite adds a single queryClient.invalidateQueries({ queryKey: ...listAllForProject({ projectId }) }) alongside existing invalidations, and three access-request mutations are retargeted from the narrow getAccessApprovalRequests(projectSlug, envSlug, requestedBy, bypassReason) key to the new broader getAccessApprovalRequestsAllForProject(projectSlug) key. Because React Query uses prefix matching for invalidation, the broader key still covers any active narrower subscriptions, so behavior is strictly a superset of the previous behavior.
Other factors
The inline comment flags a nit: useReviewAccessRequest's variables type still declares envSlug?/requestedBy? and the ReviewAccessModal caller still passes them, even though the mutation body and onSuccess no longer consume those fields. This is dead code, not a functional defect — prefix-match invalidation still works correctly and the request body to the backend is unchanged. Not worth blocking on.
Context
listAllForProject) and access approval requests (getAccessApprovalRequestsAllForProject) so lists stay fresh when filters differ from the old narrower keys. Wired from approval mutations, secret mutations,ActionBar, andSecretListView.Steps to verify
Type
Checklist
type(scope): short description(scope is optional, e.g.,fix: prevent crash on syncorfix(api): handle null response).