Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix: correct secret reference link to overview page and patch race condition on overview navigation

Scott Wilson0ec5cbcd3684
diff --git a/frontend/src/components/secrets/SecretReferenceDetails/SecretReferenceDetails.tsx b/frontend/src/components/secrets/SecretReferenceDetails/SecretReferenceDetails.tsx
index 17d18d1ec4..a71f09afd3 100644
--- a/frontend/src/components/secrets/SecretReferenceDetails/SecretReferenceDetails.tsx
+++ b/frontend/src/components/secrets/SecretReferenceDetails/SecretReferenceDetails.tsx
@@ -307,15 +307,15 @@ export const SecretReferenceTree = ({
(env: string, path: string, key: string) => {
onClose?.();
navigate({
- to: ROUTE_PATHS.SecretManager.SecretDashboardPage.path,
+ to: ROUTE_PATHS.SecretManager.OverviewPage.path,
params: {
orgId: routeParams.orgId as string,
- projectId: currentProject?.id || "",
- envSlug: env
+ projectId: currentProject?.id || ""
},
search: {
secretPath: path || "/",
- search: key || ""
+ search: key || "",
+ environments: [env]
}
});
},
diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
index 491343fdba..e56b883f6e 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
@@ -443,24 +443,53 @@ const OverviewPageContent = () => {
userAvailableEnvs?.[0]?.id ? [userAvailableEnvs[0].id] : []
);
- // Apply the environment filter when linked via the `environments` search param (e.g. from the
- // secret reference tree). This runs reactively rather than on mount only, because the tree is
- // rendered inside this page, so navigating from a node updates the param without remounting.
+ // Apply one-shot deep-link inputs to local filters, then strip them from the URL in a SINGLE
+ // navigate. These arrive either from a notification/email link (`search`, `filterBy`) or from
+ // the secret reference tree (`environments` + `search`). Handling them in one effect/navigate
+ // (rather than two racing effects) guarantees every param is cleared after it's applied. That
+ // matters most for `environments`: re-selecting the same environment from the reference tree
+ // changes the param again and re-fires this effect instead of being a no-op. Runs reactively
+ // (not mount-only) because the tree is rendered inside this page, so navigating from a node
+ // updates the params without remounting.
useEffect(() => {
- const envSlugs = routerSearch.environments;
- if (!envSlugs || envSlugs.length === 0 || userAvailableEnvs.length === 0) return;
-
- const envIds = userAvailableEnvs
- .filter((env) => envSlugs.includes(env.slug))
- .map((env) => env.id);
- if (envIds.length > 0) {
- setStoredEnvIds(envIds);
+ const { search, filterBy, environments: envSlugs, ...query } = routerSearch;
+ const hasEnvLink = Boolean(envSlugs?.length);
+
+ if (!search && !filterBy && !hasEnvLink) return;
+ // Env link present but envs not loaded yet → wait so we don't strip it before applying.
+ if (hasEnvLink && userAvailableEnvs.length === 0) return;
+
+ if (envSlugs && envSlugs.length > 0) {
+ const envIds = userAvailableEnvs
+ .filter((env) => envSlugs.includes(env.slug))
+ .map((env) => env.id);
+ if (envIds.length > 0) {
+ setStoredEnvIds(envIds);
+ }
}
- // Treat the param as a one-shot deep-link input (mirrors the `search` handling below) so it
- // doesn't override the user's stored env filter on subsequent renders.
- navigate({ search: (prev) => ({ ...prev, environments: [] }), replace: true });
- }, [routerSearch.environments?.join(","), userAvailableEnvs.length]);
+ if (search || filterBy) {
+ const initialFilter = { ...DEFAULT_FILTER_STATE };
+ if (filterBy) {
+ const rowType = Object.values(RowType).find((rt) => rt === filterBy);
+ if (rowType) {
+ initialFilter[rowType] = true;
+ }
+ }
+ setFilter(initialFilter);
+
+ if (search) {
+ setSearchFilter(search as string);
+ }
+ }
+
+ navigate({ search: query, replace: true });
+ }, [
+ routerSearch.search,
+ routerSearch.filterBy,
+ routerSearch.environments?.join(","),
+ userAvailableEnvs.length
+ ]);
const filteredEnvs = useMemo(() => {
if (!storedEnvIds.length) return [];
@@ -875,28 +904,6 @@ const OverviewPageContent = () => {
}
}, [routerSearch.dynamicSecretId, dynamicSecrets?.map((ds) => ds.id).join(",")]);
- // Apply search and/or resource type filter when linked via notification/email
- useEffect(() => {
- if (routerSearch.search || routerSearch.filterBy) {
- const { search, filterBy, ...query } = routerSearch;
- // temp workaround until we transition state to query params
- navigate({ search: query, replace: true });
-
- const initialFilter = { ...DEFAULT_FILTER_STATE };
- if (filterBy) {
- const rowType = Object.values(RowType).find((rt) => rt === filterBy);
- if (rowType) {
- initialFilter[rowType] = true;
- }
- }
- setFilter(initialFilter);
-
- if (search) {
- setSearchFilter(search as string);
- }
- }
- }, [routerSearch.search, routerSearch.filterBy]);
-
const handleViewCommitHistory = async (envSlug: string, preloadedFolderId?: string) => {
if (!subscription?.pitRecovery) {
handlePopUpOpen("upgradePlan", {