From ebe470e14aca1f4be9f7dbc4b3810c221995e61d Mon Sep 17 00:00:00 2001 From: Shashwat Dixit Date: Tue, 23 Dec 2025 01:16:06 +0530 Subject: [PATCH] fix: allow empty secret values when setting secrets from .env file Problem: - When running `infisical secrets set --file .env`, if any secret has an empty value, the CLI prints "Secret key 'X' has an empty value" and exits - The message is ambiguous - unclear if it's an error, warning, or info - The entire operation fails and no secrets are set - This is inconsistent with the Infisical UI which allows empty values Solution: - Remove the restriction that blocks empty secret values - Display an informational warning when empty values are detected - Continue processing and set all secrets from the file - Only block on empty keys (which are invalid), not empty values Changes: - packages/util/secrets.go: Replace PrintErrorMessageAndExit with warning message for empty values - packages/util/secrets.go: Update validation to only check for empty keys Testing: - Created .env file with empty value (KEY1=value1, KEY2=, KEY3=value3) - Verified all secrets are set successfully - Verified warning is displayed for empty value - Verified existing functionality still works for non-empty values Fixes #87 --- packages/util/secrets.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/util/secrets.go b/packages/util/secrets.go index 0dd69c05..93ae98d3 100644 --- a/packages/util/secrets.go +++ b/packages/util/secrets.go @@ -652,7 +652,7 @@ func SetRawSecrets(secretArgs []string, secretType string, environmentName strin PrintErrorMessageAndExit(err.Error()) } if strings.TrimSpace(value) == "" { - PrintErrorMessageAndExit(fmt.Sprintf("Secret key '%s' has an empty value", key)) + PrintWarning(fmt.Sprintf("Secret key '%s' has an empty value", key)) } secretArgs = append(secretArgs, fmt.Sprintf("%s=%s", key, value)) } @@ -705,8 +705,8 @@ func SetRawSecrets(secretArgs []string, secretType string, environmentName strin for _, arg := range secretArgs { splitKeyValueFromArg := strings.SplitN(arg, "=", 2) - if splitKeyValueFromArg[0] == "" || splitKeyValueFromArg[1] == "" { - PrintErrorMessageAndExit("ensure that each secret has a none empty key and value. Modify the input and try again") + if splitKeyValueFromArg[0] == "" { + PrintErrorMessageAndExit("ensure that each secret has a non empty key. Modify the input and try again") } if unicode.IsNumber(rune(splitKeyValueFromArg[0][0])) {