Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix 301 error for vault 1.0.0
adilson91ce7859b147
diff --git a/backend/src/services/app-connection/hc-vault/hc-vault-connection-fns.ts b/backend/src/services/app-connection/hc-vault/hc-vault-connection-fns.tsindex a0b39f4cec..8895ef59c2 100644--- a/backend/src/services/app-connection/hc-vault/hc-vault-connection-fns.ts+++ b/backend/src/services/app-connection/hc-vault/hc-vault-connection-fns.ts@@ -673,20 +673,37 @@ export const listHCVaultMounts = async (const targetNamespace = namespace || connection.credentials.namespace;- const { data } = await requestWithHCVaultGateway<THCVaultMountResponse>(- connection,- gatewayService,- gatewayV2Service,- {- url: `${instanceUrl}/v1/sys/mounts`,- method: "GET",- headers: {- "X-Vault-Token": accessToken,- ...(targetNamespace ? { "X-Vault-Namespace": targetNamespace } : {})- }- },- gatewayDetails- );+ const fetchMounts = (namespaceHeader?: string) =>+ requestWithHCVaultGateway<THCVaultMountResponse>(+ connection,+ gatewayService,+ gatewayV2Service,+ {+ url: `${instanceUrl}/v1/sys/mounts`,+ method: "GET",+ headers: {+ "X-Vault-Token": accessToken,+ ...(namespaceHeader ? { "X-Vault-Namespace": namespaceHeader } : {})+ }+ },+ gatewayDetails+ );++ let data: THCVaultMountResponse;+ try {+ ({ data } = await fetchMounts(targetNamespace));+ } catch (error: unknown) {+ // vault 1.0.0 does not support namespace root or /, so we need to handle this case+ // if the error is 301 and the namespace is root or /, try to fetch mounts without the namespace header+ if (+ ((error instanceof AxiosError && error.response?.status === 301) || isGateway301Error(error)) &&+ (targetNamespace === "/" || targetNamespace === "root")+ ) {+ ({ data } = await fetchMounts());+ } else {+ throw error;+ }+ }const mounts: THCVaultMount[] = [];