{"record":{"id":"6b4e310e3e703d0e","repo":"charmbracelet/crush","slug":"s-s-expects-true-false-got-q","errorCode":null,"errorMessage":"%s: --%s expects true/false, got %q","messagePattern":"(.+?): --(.+?) expects true/false, got %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/shellconfig/flags.go","lineNumber":123,"sourceCode":"\tswitch spec.kind {\n\tcase flagString:\n\t\tv, err := nextArg(args, i, name)\n\t\tif err != nil {\n\t\t\treturn nil, 0, err\n\t\t}\n\t\treturn v, i + 2, nil\n\n\tcase flagBoolTrue:\n\t\treturn true, i + 1, nil\n\n\tcase flagBool:\n\t\tv, err := nextArg(args, i, name)\n\t\tif err != nil {\n\t\t\treturn nil, 0, err\n\t\t}\n\t\tb, err := parseBool(v)\n\t\tif err != nil {\n\t\t\treturn nil, 0, fmt.Errorf(\"%s: --%s expects true/false, got %q\", args[0], name, v)\n\t\t}\n\t\treturn b, i + 2, nil\n\n\tcase flagInt:\n\t\tv, err := nextArg(args, i, name)\n\t\tif err != nil {\n\t\t\treturn nil, 0, err\n\t\t}\n\t\tn, err := strconv.ParseInt(v, 10, 64)\n\t\tif err != nil {\n\t\t\treturn nil, 0, fmt.Errorf(\"%s: --%s expects an integer, got %q\", args[0], name, v)\n\t\t}\n\t\treturn n, i + 2, nil\n\n\tcase flagFloat:\n\t\tv, err := nextArg(args, i, name)\n\t\tif err != nil {\n\t\t\treturn nil, 0, err","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/shellconfig/flags.go#L105-L141","documentation":"parseFlagValue in internal/shellconfig/flags.go validates boolean flag values with parseBool. When a --flag declared as flagBool is followed by a value that is not true/false, the error \"<cmd>: --<flag> expects true/false, got %q\" is returned during applyFlags while building the config. Config loading aborts at this point.","triggerScenarios":"Writing a crushrc builtin invocation like `provider --debug yes` or `--verbose 1` where the flag was declared flagBool and parseBool only accepts true/false (Go strconv.ParseBool forms, per parseBool's implementation).","commonSituations":"Users copying CLI conventions from other tools that accept yes/no/1/0; typos like 'ture'; quoting mistakes that pass an empty string as the value.","solutions":["Replace the value with a literal true or false.","Check the flag's declared type in the builtin's flag spec; integer/number flags use different messages.","Verify the value isn't an empty string caused by shell quoting (`--flag \"\"`).","If broader value acceptance is needed, extend parseBool or declare the flag with a different type."],"exampleFix":"// before (crushrc)\noptions --debug yes\n// after\noptions --debug true","handlingStrategy":"validation","validationCode":"func isBoolLiteral(v string) bool {\n\t_, err := strconv.ParseBool(v)\n\treturn err == nil\n}","typeGuard":null,"tryCatchPattern":"err := cfg.Apply(args)\nif err != nil && strings.Contains(err.Error(), \"expects true/false\") {\n\t// surface exact cmd+flag from the message prefix to the user\n}","preventionTips":["Only write literal true/false for boolean flags in crushrc files.","Check each builtin's flag spec (--help or docs) for expected value types.","Avoid quoting values so empty strings don't slip through.","Add a config linter/parse test for crushrc files in CI."],"tags":["config","flags","validation"],"backgroundTag":"invalid-flag-value","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}