diff --git a/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx b/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx index 98f42923a..c5c119896 100644 --- a/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx +++ b/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx @@ -4,6 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import * as Popover from "@radix-ui/react-popover"; import { useNavigate } from "@tanstack/react-router"; +import { createNotification } from "@app/components/notifications"; import { ROUTE_PATHS } from "@app/const/routes"; import { useProject } from "@app/context"; import { useDebounce, useToggle } from "@app/hooks"; @@ -312,6 +313,22 @@ export const InfisicalSecretInput = forwardRef( const handleClickSegment = useCallback( (segment: string, allSegments: string[]) => { + if (!projectId) { + createNotification({ + text: "Project ID is not set", + type: "error" + }); + return; + } + + if (allSegments.length === 0) { + createNotification({ + text: "Invalid secret reference", + type: "error" + }); + return; + } + if (allSegments.length === 1) { navigate({ search: (prev) => ({ @@ -330,6 +347,14 @@ export const InfisicalSecretInput = forwardRef( if (allSegments.length > 2) { const pathSegments = allSegments.slice(1, -1); for (let i = 0; i < pathSegments.length; i += 1) { + if (!pathSegments[i]) { + createNotification({ + text: "Invalid secret reference", + type: "error" + }); + return; + } + const pathSegment = pathSegments[i]; folderPath += `${pathSegment}`; if (pathSegment === segment) {