Skip to content

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

feat(secret-ref): updated reference corner cases of trailing slashes

akhilmhdh8a237af4ac7c
diff --git a/cli/packages/util/secrets.go b/cli/packages/util/secrets.go
index 80d51fcf5a..d49e926072 100644
--- a/cli/packages/util/secrets.go
+++ b/cli/packages/util/secrets.go
@@ -358,10 +358,9 @@ func ExpandSecrets(secrets []models.SingleEnvironmentVariable, infisicalToken st
}
expandedVal := recursivelyExpandSecret(expandedSecs, interpolatedSecs, func(env string, secPaths []string, secKey string) string {
+ secPaths = append([]string{"/"}, secPaths...)
secPath := path.Join(secPaths...)
- if secPath == "" {
- secPath = "/"
- }
+
secPathDot := strings.Join(secPaths, ".")
uniqKey := fmt.Sprintf("%s.%s", env, secPathDot)
diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/ServiceTokenSection/AddServiceTokenModal.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/ServiceTokenSection/AddServiceTokenModal.tsx
index 82fbf9edcc..a44db233b4 100644
--- a/frontend/src/views/Settings/ProjectSettingsPage/components/ServiceTokenSection/AddServiceTokenModal.tsx
+++ b/frontend/src/views/Settings/ProjectSettingsPage/components/ServiceTokenSection/AddServiceTokenModal.tsx
@@ -45,7 +45,14 @@ const schema = yup.object({
.array(
yup.object({
environment: yup.string().max(50).required().label("Environment"),
- secretPath: yup.string().required().default("/").label("Secret Path")
+ secretPath: yup
+ .string()
+ .required()
+ .default("/")
+ .label("Secret Path")
+ .transform((val) =>
+ typeof val === "string" && val.at(-1) === "/" && val.length > 1 ? val.slice(0, -1) : val
+ )
})
)
.min(1)