{"record":{"id":"ee8762792f6d7476","repo":"yudai/gotty","slug":"invalid-bool-expression-v-use-true-false","errorCode":null,"errorMessage":"invalid bool expression: %v, use true/false","messagePattern":"invalid bool expression: (.+?), use true/false","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"utils/default.go","lineNumber":28,"sourceCode":"func ApplyDefaultValues(struct_ interface{}) (err error) {\n\to := structs.New(struct_)\n\n\tfor _, field := range o.Fields() {\n\t\tdefaultValue := field.Tag(\"default\")\n\t\tif defaultValue == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tvar val interface{}\n\t\tswitch field.Kind() {\n\t\tcase reflect.String:\n\t\t\tval = defaultValue\n\t\tcase reflect.Bool:\n\t\t\tif defaultValue == \"true\" {\n\t\t\t\tval = true\n\t\t\t} else if defaultValue == \"false\" {\n\t\t\t\tval = false\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"invalid bool expression: %v, use true/false\", defaultValue)\n\t\t\t}\n\t\tcase reflect.Int:\n\t\t\tval, err = strconv.Atoi(defaultValue)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tdefault:\n\t\t\tval = field.Value()\n\t\t}\n\t\tfield.Set(val)\n\t}\n\treturn nil\n}\n","sourceCodeStart":10,"sourceCodeEnd":42,"githubUrl":"https://github.com/yudai/gotty/blob/a080c85cbc59226c94c6941ad8c395232d72d517/utils/default.go#L10-L42","documentation":"ApplyDefaultValues() reflects over config struct fields and converts each field's default value string to the field's type. For reflect.Bool fields, only the exact strings \"true\" and \"false\" are accepted; anything else returns this error, aborting config loading.","triggerScenarios":"A config file (or default-value registration) supplies a boolean option a value other than true/false — e.g. yes, no, 1, 0, on, off, True.","commonSituations":"Users migrating from YAML/INI tools that accept yes/no; writing `True` with a capital letter; using 1/0 as seen in other CLI tools.","solutions":["Use exactly true or false (lowercase) in ~/.gotty or the config file","Replace yes/no or 1/0 with true/false","Check capitalization — \"True\"/\"FALSE\" are rejected"],"exampleFix":"// before\npermit_write = yes\n// after\npermit_write = true","handlingStrategy":"validation","validationCode":"func validBool(s string) bool { return s == \"true\" || s == \"false\" }\n// check config values for bool options before ApplyDefaultValues","typeGuard":null,"tryCatchPattern":"if err := utils.ApplyDefaultValues(options, defaults); err != nil {\n    if strings.Contains(err.Error(), \"invalid bool expression\") {\n        log.Fatalf(\"config bool value must be true/false: %v\", err)\n    }\n}","preventionTips":["Use lowercase true/false only in ~/.gotty","Never use yes/no, 1/0, or capitalized True/FALSE","Lint config files for bool options before deployment"],"tags":["configuration","boolean","parsing"],"backgroundTag":"invalid-boolean-value","analyzedSha":"a080c85cbc59226c94c6941ad8c395232d72d517","analyzedAt":"2026-09-02T16:42:38.150Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}