Skip to content

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

fix: refine try/catch

Scott Wilsonec12d578625c
diff --git a/frontend/src/pages/secret-manager/IntegrationsListPage/route.tsx b/frontend/src/pages/secret-manager/IntegrationsListPage/route.tsx
index f58022d8d4..7a5f706225 100644
--- a/frontend/src/pages/secret-manager/IntegrationsListPage/route.tsx
+++ b/frontend/src/pages/secret-manager/IntegrationsListPage/route.tsx
@@ -3,7 +3,12 @@ import { zodValidator } from "@tanstack/zod-adapter";
import { z } from "zod";
import { workspaceKeys } from "@app/hooks/api";
-import { fetchSecretSyncsByProjectId, secretSyncKeys } from "@app/hooks/api/secretSyncs";
+import { TIntegration } from "@app/hooks/api/integrations/types";
+import {
+ fetchSecretSyncsByProjectId,
+ secretSyncKeys,
+ TSecretSync
+} from "@app/hooks/api/secretSyncs";
import { fetchWorkspaceIntegrations } from "@app/hooks/api/workspace/queries";
import { IntegrationsListPageTabs } from "@app/types/integrations";
@@ -20,37 +25,40 @@ export const Route = createFileRoute(
validateSearch: zodValidator(IntegrationsListPageQuerySchema),
beforeLoad: async ({ context, search, params: { projectId } }) => {
if (!search.selectedTab) {
+ let secretSyncs: TSecretSync[];
+
try {
- const secretSyncs = await context.queryClient.ensureQueryData({
+ secretSyncs = await context.queryClient.ensureQueryData({
queryKey: secretSyncKeys.list(projectId),
queryFn: () => fetchSecretSyncsByProjectId(projectId)
});
+ } catch {
+ throw redirect({
+ to: "/secret-manager/$projectId/integrations",
+ params: {
+ projectId
+ },
+ search: { selectedTab: IntegrationsListPageTabs.NativeIntegrations }
+ });
+ }
- if (secretSyncs.length) {
- throw redirect({
- to: "/secret-manager/$projectId/integrations",
- params: {
- projectId
- },
- search: { selectedTab: IntegrationsListPageTabs.SecretSyncs }
- });
- }
+ if (secretSyncs.length) {
+ throw redirect({
+ to: "/secret-manager/$projectId/integrations",
+ params: {
+ projectId
+ },
+ search: { selectedTab: IntegrationsListPageTabs.SecretSyncs }
+ });
+ }
- const integrations = await context.queryClient.ensureQueryData({
+ let integrations: TIntegration[];
+ try {
+ integrations = await context.queryClient.ensureQueryData({
queryKey: workspaceKeys.getWorkspaceIntegrations(projectId),
queryFn: () => fetchWorkspaceIntegrations(projectId)
});
-
- if (integrations.length) {
- throw redirect({
- to: "/secret-manager/$projectId/integrations",
- params: {
- projectId
- },
- search: { selectedTab: IntegrationsListPageTabs.NativeIntegrations }
- });
- }
-
+ } catch {
throw redirect({
to: "/secret-manager/$projectId/integrations",
params: {
@@ -58,7 +66,9 @@ export const Route = createFileRoute(
},
search: { selectedTab: IntegrationsListPageTabs.SecretSyncs }
});
- } catch {
+ }
+
+ if (integrations.length) {
throw redirect({
to: "/secret-manager/$projectId/integrations",
params: {
@@ -67,6 +77,14 @@ export const Route = createFileRoute(
search: { selectedTab: IntegrationsListPageTabs.NativeIntegrations }
});
}
+
+ throw redirect({
+ to: "/secret-manager/$projectId/integrations",
+ params: {
+ projectId
+ },
+ search: { selectedTab: IntegrationsListPageTabs.SecretSyncs }
+ });
}
return {