Skip to content

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

Throw if file and args secrets are used on secret set command

carlosmonastyrskiad6f285b59eb
diff --git a/cli/packages/cmd/secrets.go b/cli/packages/cmd/secrets.go
index 1ca53e86d5..8e9f5d63bd 100644
--- a/cli/packages/cmd/secrets.go
+++ b/cli/packages/cmd/secrets.go
@@ -145,7 +145,10 @@ var secretsSetCmd = &cobra.Command{
DisableFlagsInUseLine: true,
Args: func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("file") {
- return cobra.ExactArgs(0)(cmd, args)
+ if len(args) > 0 {
+ return fmt.Errorf("secrets cannot be provided as command-line arguments when the --file option is used. Please choose either file-based or argument-based secret input")
+ }
+ return nil
}
return cobra.MinimumNArgs(1)(cmd, args)
},