Skip to content

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

feat(run): ensure that the project has the requested environment

Mahyar Mirrashed62aa80a1041c
diff --git a/cli/packages/cmd/run.go b/cli/packages/cmd/run.go
index d2a631e1b6..bb23edf32d 100644
--- a/cli/packages/cmd/run.go
+++ b/cli/packages/cmd/run.go
@@ -136,6 +136,18 @@ var runCmd = &cobra.Command{
util.HandleError(err, "Unable to parse flag")
}
+ log.Debug().Msgf("Confirming selected environment is valid: %s", environmentName)
+
+ hasEnvironment, err := confirmProjectHasEnvironment(projectId, environmentName, token.Token)
+ if err != nil {
+ util.HandleError(err, "Could not confirm project has environment")
+ }
+ if !hasEnvironment {
+ util.HandleError(fmt.Errorf("project '%s' does not have environment '%s'", projectId, environmentName))
+ }
+
+ log.Debug().Msgf("Project '%s' has environment '%s'", projectId, environmentName)
+
request := models.GetAllSecretsParameters{
Environment: environmentName,
WorkspaceId: projectId,