Skip to content

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

print error message when projectId flag is not passed for set secret

Maidul Islam4ba529f22ddd
diff --git a/cli/packages/cmd/secrets.go b/cli/packages/cmd/secrets.go
index 1f64ee9b6a..7434587277 100644
--- a/cli/packages/cmd/secrets.go
+++ b/cli/packages/cmd/secrets.go
@@ -187,6 +187,10 @@ var secretsSetCmd = &cobra.Command{
var secretOperations []models.SecretSetOperation
if token != nil && (token.Type == util.SERVICE_TOKEN_IDENTIFIER || token.Type == util.UNIVERSAL_AUTH_TOKEN_IDENTIFIER) {
+ if projectId == "" {
+ util.PrintErrorMessageAndExit("When using service tokens or machine identities, you must set the --projectId flag")
+ }
+
secretOperations, err = util.SetRawSecrets(args, secretType, environmentName, secretsPath, projectId, token)
} else {
workspaceFile, err := util.GetWorkSpaceFromFile()