{"record":{"id":"80d2cb6f2b3bfc49","repo":"docker/cli","slug":"invalid-boolean-s","errorCode":null,"errorMessage":"invalid boolean: %s","messagePattern":"invalid boolean: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/loader/interpolate.go","lineNumber":70,"sourceCode":"}\n\nfunc toInt(value string) (any, error) {\n\treturn strconv.Atoi(value)\n}\n\nfunc toFloat(value string) (any, error) {\n\treturn strconv.ParseFloat(value, 64)\n}\n\n// should match http://yaml.org/type/bool.html\nfunc toBoolean(value string) (any, error) {\n\tswitch strings.ToLower(value) {\n\tcase \"y\", \"yes\", \"true\", \"on\":\n\t\treturn true, nil\n\tcase \"n\", \"no\", \"false\", \"off\":\n\t\treturn false, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid boolean: %s\", value)\n\t}\n}\n\nfunc interpolateConfig(configDict map[string]any, opts interp.Options) (map[string]any, error) {\n\treturn interp.Interpolate(configDict, opts)\n}\n","sourceCodeStart":52,"sourceCodeEnd":77,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/loader/interpolate.go#L52-L77","documentation":"Returned by the toBoolean caster when an interpolated value for a boolean compose field is not one of the accepted YAML-bool tokens (loader/interpolate.go:63-71). Accepted values are y/yes/true/on (true) and n/no/false/off (false), case-insensitive; anything else fails.","triggerScenarios":"Setting a boolean-typed compose field (e.g. privileged, tty, read_only, healthcheck.disable, volumes.[].read_only, *.external) via interpolation to a value outside the accepted set. Reached at interpolate.go:70 via the TypeCastMapping toBoolean.","commonSituations":"Using 1/0 or enabled/disabled instead of true/false; an env var holding an unexpected string; locale-specific tokens like 'ja'/'nein'.","solutions":["Use one of yes/no/true/false/on/off (case-insensitive) for the interpolated value.","Set the env var backing the field to a valid boolean token.","Provide a default in the interpolation, e.g. ${TTY:-false}."],"exampleFix":"# before\nenvironment:\n  TTY_FLAG: enabled\nservices:\n  app:\n    tty: ${TTY_FLAG}\n# after\nenvironment:\n  TTY_FLAG: \"true\"\nservices:\n  app:\n    tty: ${TTY_FLAG:-false}","handlingStrategy":"validation","validationCode":"var validBools = map[string]bool{\n    \"y\": true, \"yes\": true, \"true\": true, \"on\": true,\n    \"n\": true, \"no\": true, \"false\": true, \"off\": true,\n}\nfunc isValidBool(v string) bool {\n    _, ok := validBools[strings.ToLower(v)]\n    return ok\n}\n// if !isValidBool(os.Getenv(\"TTY\")) { return fmt.Errorf(\"TTY must be yes/no/true/false/on/off\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use yes/no/true/false/on/off (case-insensitive) for boolean compose fields.","Give boolean fields a default (${VAR:-false}).","Avoid 1/0 or custom tokens for booleans."],"tags":["compose","interpolation","boolean","type-cast"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}