Skip to content

fix(frontend): invalidate approval request queries at project scope#6135

Merged
victorvhs017 merged 2 commits into
mainfrom
fix/approvals-invalidate-query
Apr 23, 2026
Merged

fix(frontend): invalidate approval request queries at project scope#6135
victorvhs017 merged 2 commits into
mainfrom
fix/approvals-invalidate-query

Conversation

@victorvhs017
Copy link
Copy Markdown
Contributor

Context

  • Frontend: Invalidate project-scoped React Query keys for secret approval requests (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, and SecretListView.

Steps to verify

  1. Secret/access approval flows: act on requests and secrets; confirm approval lists and counts update without reload.

Type

  • Fix
  • Feature
  • Improvement
  • Breaking
  • Docs
  • Chore

Checklist

  • Title follows the conventional commit format: type(scope): short description (scope is optional, e.g., fix: prevent crash on sync or fix(api): handle null response).
  • Tested locally
  • Updated docs (if needed)
  • Updated CLAUDE.md files (if needed)
  • Read the contributing guide

@maidul98
Copy link
Copy Markdown
Collaborator

maidul98 commented Apr 23, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread frontend/src/hooks/api/accessApproval/mutation.tsx
@victorvhs017 victorvhs017 requested a review from akhilmhdh April 23, 2026 01:09
@victorvhs017 victorvhs017 merged commit 5b173ca into main Apr 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants