{"record":{"id":"7e907d87c2be7cf4","repo":"larksuite/cli","slug":"s-must-be-a-boolean","errorCode":null,"errorMessage":"%s must be a boolean","messagePattern":"(.+?) must be a boolean","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":432,"sourceCode":"\t\ttext, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be a string\", path)\n\t\t}\n\t\tlength := len([]rune(text))\n\t\tif constraint.MinLength != nil && length < *constraint.MinLength {\n\t\t\treturn fmt.Errorf(\"%s must contain at least %d characters\", path, *constraint.MinLength)\n\t\t}\n\t\tif constraint.MaxLength != nil && length > *constraint.MaxLength {\n\t\t\treturn fmt.Errorf(\"%s must contain at most %d characters\", path, *constraint.MaxLength)\n\t\t}\n\t\tif len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, text) {\n\t\t\treturn fmt.Errorf(\"%s must be one of: %s\", path, strings.Join(constraint.Enum, \", \"))\n\t\t}\n\t\treturn nil\n\tcase typedBooleanShape:\n\t\tboolean, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be a boolean\", path)\n\t\t}\n\t\tif len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, boolean) {\n\t\t\treturn fmt.Errorf(\"%s has an unsupported boolean value\", path)\n\t\t}\n\t\treturn nil\n\tcase typedIntegerShape:\n\t\tnumber, ok := validationInteger(value)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be an integer\", path)\n\t\t}\n\t\tif constraint.Minimum != nil && number < *constraint.Minimum {\n\t\t\treturn fmt.Errorf(\"%s must be at least %d\", path, *constraint.Minimum)\n\t\t}\n\t\tif constraint.Maximum != nil && number > *constraint.Maximum {\n\t\t\treturn fmt.Errorf(\"%s must be at most %d\", path, *constraint.Maximum)\n\t\t}\n\t\tif len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, number) {\n\t\t\treturn fmt.Errorf(\"%s has an unsupported integer value\", path)","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L414-L450","documentation":"A field whose schema is a boolean received a JSON value that is not bool (e.g. the string \"true\" or the number 1). validateJSONValueAgainstShape type-asserts value.(bool) and fails. JSON does not coerce between strings and booleans, so the literal type must be bool.","triggerScenarios":"Passing \"true\"/\"false\" (quoted strings) where a JSON boolean is required; supplying 0/1 instead of true/false in a nested object or JSON body field bound through validateCompiledValue.","commonSituations":"Building JSON bodies by hand or via shell interpolation where booleans get quoted; configuration files where flags are stored as strings; converting from a language where 0/1 are truthy values.","solutions":["Pass a real boolean (true/false) instead of a quoted string or number","Unquote the value in templates/scripts: use true not \"true\"","If the value originates from config, parse it to bool before binding","Confirm the field really is boolean via `schema`; if it accepts a string enum, use the string form"],"exampleFix":"// before\nbody := fmt.Sprintf(`{\"enabled\": \"%v\"}`, enabled) // \"enabled\": \"true\"\n// after\nbody := fmt.Sprintf(`{\"enabled\": %t}`, enabled)    // \"enabled\": true","handlingStrategy":"type-guard","validationCode":"func ensureBool(v any) error {\n    if _, ok := v.(bool); !ok {\n        return fmt.Errorf(\"expected JSON boolean, got %T\", v)\n    }\n    return nil\n}","typeGuard":"func isJSONBool(v any) bool { _, ok := v.(bool); return ok }","tryCatchPattern":"if err := bind(field, v); err != nil {\n    if strings.Contains(err.Error(), \"must be a boolean\") {\n        return fmt.Errorf(\"field %s requires literal true/false, not a quoted string: %w\", field, err)\n    }\n    return err\n}","preventionTips":["Use typed structs (bool fields) instead of map[string]any for request bodies","In templates, emit %t not \"%v\" for boolean fields","Parse config flags with strconv.ParseBool instead of passing raw strings","Never quote true/false when building JSON by hand"],"tags":["validation","cli","json","type-mismatch"],"backgroundTag":"schema-type-mismatch","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}