{"record":{"id":"4831ee1c1971efb8","repo":"pulumi/pulumi","slug":"invalid-value-for-s-s-expected-true-or-false","errorCode":null,"errorMessage":"invalid value for %s: %s (expected true or false)","messagePattern":"invalid value for (.+?): (.+?) \\(expected true or false\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/esc/cli/env_setting_deletion_protected.go","lineNumber":41,"sourceCode":"const settingDeletionProtected settingName = \"deletion-protected\"\n\ntype DeletionProtectedSetting struct{}\n\nfunc (s *DeletionProtectedSetting) KebabName() string {\n\treturn \"deletion-protected\"\n}\n\nfunc (s *DeletionProtectedSetting) HelpText() string {\n\treturn \"Enable or disable deletion protection\"\n}\n\n// ValidateValue accepts only \"true\" and \"false\" strings, unlike the general env {get,set} commands\n// which parse YAML and accept broader boolean values like \"yes\", \"no\", \"on\", \"off\", etc.\n// This restriction maintains compatibility while limiting the accepted subset to a well-defined\n// interface that can be reliably parsed and validated.\nfunc (s *DeletionProtectedSetting) ValidateValue(raw string) (bool, error) {\n\tif raw != \"true\" && raw != \"false\" {\n\t\treturn false, fmt.Errorf(\"invalid value for %s: %s (expected true or false)\", s.KebabName(), raw)\n\t}\n\treturn raw == \"true\", nil\n}\n\nfunc (s *DeletionProtectedSetting) GetValue(settings *client.EnvironmentSettings) bool {\n\treturn settings.DeletionProtected\n}\n\nfunc (s *DeletionProtectedSetting) SetValue(req *client.PatchEnvironmentSettingsRequest, value bool) {\n\treq.DeletionProtected = &value\n}\n","sourceCodeStart":23,"sourceCodeEnd":53,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/esc/cli/env_setting_deletion_protected.go#L23-L53","documentation":"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.","triggerScenarios":"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\".","commonSituations":"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.","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"],"exampleFix":"// before\n$ pulumi esc env set-settings my-env deletion-protected yes\n// after\n$ pulumi esc env set-settings my-env deletion-protected true","handlingStrategy":"validation","validationCode":"const isValidSettingBool = (v) => v === \"true\" || v === \"false\";\nif (!isValidSettingBool(rawValue)) {\n  throw new Error(`deletion-protected must be exactly \"true\" or \"false\", got: ${rawValue}`);\n}","typeGuard":"const asStrictBool = (v) => (v === \"true\" ? true : v === \"false\" ? false : null);","tryCatchPattern":null,"preventionTips":["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"],"tags":["validation","cli","boolean","esc-settings"],"backgroundTag":"invalid-boolean-value","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}