pulumi/pulumi · error
invalid value for %s: %s (expected true or false)
Error message
invalid value for %s: %s (expected true or false)
What it means
DeletionProtectedSetting.ValidateValue accepts only the literal strings "true" and "false" for the deletion-protection setting. Unlike general `env get/set`, which parse YAML and accept broader booleans (yes/no/on/off), settings commands restrict values to a well-defined, reliably parsed interface. Any other string produces this error.
Source
Thrown at pkg/cmd/esc/cli/env_setting_deletion_protected.go:41
const settingDeletionProtected settingName = "deletion-protected"
type DeletionProtectedSetting struct{}
func (s *DeletionProtectedSetting) KebabName() string {
return "deletion-protected"
}
func (s *DeletionProtectedSetting) HelpText() string {
return "Enable or disable deletion protection"
}
// ValidateValue accepts only "true" and "false" strings, unlike the general env {get,set} commands
// which parse YAML and accept broader boolean values like "yes", "no", "on", "off", etc.
// This restriction maintains compatibility while limiting the accepted subset to a well-defined
// interface that can be reliably parsed and validated.
func (s *DeletionProtectedSetting) ValidateValue(raw string) (bool, error) {
if raw != "true" && raw != "false" {
return false, fmt.Errorf("invalid value for %s: %s (expected true or false)", s.KebabName(), raw)
}
return raw == "true", nil
}
func (s *DeletionProtectedSetting) GetValue(settings *client.EnvironmentSettings) bool {
return settings.DeletionProtected
}
func (s *DeletionProtectedSetting) SetValue(req *client.PatchEnvironmentSettingsRequest, value bool) {
req.DeletionProtected = &value
}
View on GitHub (pinned to 793f7b2e16)
Solutions
- Use exactly `true` or `false` (lowercase, no quotes needed in shell): `pulumi esc env set-settings my-env deletion-protected true`
- Normalize the value before invoking: `value="${value,,}"` in bash to lowercase it first
- If scripting, validate with a case statement on "true"/"false" before calling the CLI
Example fix
// before $ pulumi esc env set-settings my-env deletion-protected yes // after $ pulumi esc env set-settings my-env deletion-protected true
Defensive patterns
Strategy: validation
Validate before calling
const isValidSettingBool = (v) => v === "true" || v === "false";
if (!isValidSettingBool(rawValue)) {
throw new Error(`deletion-protected must be exactly "true" or "false", got: ${rawValue}`);
} Type guard
const asStrictBool = (v) => (v === "true" ? true : v === "false" ? false : null);
Prevention
- Never use YAML-style booleans (yes/no/on/off) with settings commands
- Lowercase and validate boolean values in wrapper scripts before calling the CLI
- Remember: only "true"/"false" (exact strings) are accepted
When it happens
Trigger: Running `pulumi esc env set-settings <env> deletion-protected <value>` (or the settings get/set path that calls ValidateValue) where value is not exactly "true" or "false" — e.g. "yes", "True", "1", "enabled".
Common situations: Users habituating to YAML booleans pass "yes" or "on"; shell scripts pass "TRUE" with different casing; copying boolean syntax from other CLIs that accept 0/1.
Related errors
- stack name must not be empty
- organization name must be 'organization'
- no Pulumi.yaml project file found; either run this command f
- no environment name specified
- referring to an environment name ('env' or 'org/env') withou
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/4831ee1c1971efb8.
Report an issue: GitHub.