larksuite/cli · error
invalid boolean
Error message
invalid boolean
What it means
parseBool accepts only the literal strings "true" and "false". It is used by shapeForType when lowering the enum of a bool-typed field from the schema tag; any other enum member string for a boolean field fails here and is surfaced (wrapped as "enum value %q is not boolean"). Go's strconv.ParseBool flexibility (1/0/TRUE/True) is intentionally not accepted.
Source
Thrown at shortcuts/common/typed_compile_data.go:458
return true
}
}
return false
}
func hasStringConstraints(s schemaTag) bool { return s.minLength != nil || s.maxLength != nil }
func hasNumberConstraints(s schemaTag) bool { return s.minimum != nil || s.maximum != nil }
func hasItemConstraints(s schemaTag) bool { return s.minItems != nil || s.maxItems != nil }
func implementsCustomEncoding(t reflect.Type) bool {
return t.Implements(jsonMarshalerType) || reflect.PointerTo(t).Implements(jsonMarshalerType) || t.Implements(textMarshalerType) || reflect.PointerTo(t).Implements(textMarshalerType)
}
func parseBool(raw string) (bool, error) {
switch raw {
case "true":
return true, nil
case "false":
return false, nil
default:
return false, fmt.Errorf("invalid boolean")
}
}
View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Change the enum tag to lowercase literals only, e.g. enum:"true,false".
- Remove the enum from the bool field if both values are allowed (an unconstrained bool needs no enum).
- If 0/1 semantics are needed, change the Go field type to int and declare an integer enum instead.
Example fix
// before
type Data struct {
Enabled bool `schema:"enum:1,0"`
}
// after
type Data struct {
Enabled bool `schema:"enum:true,false"`
} Defensive patterns
Strategy: validation
Validate before calling
func validBoolEnum(tag string) error {
for _, v := range strings.Split(tag, ",") {
if v != "true" && v != "false" {
return fmt.Errorf("enum value %q is not exactly true/false", v)
}
}
return nil
} Prevention
- Only use lowercase "true"/"false" in enum tags on bool fields — not 0/1, TRUE, or True.
- Drop the enum tag entirely for unconstrained booleans.
- Use an int field with an integer enum when tri-state or numeric bools are needed.
When it happens
Trigger: Declaring a bool field in the data/args struct with a schema enum tag containing a value other than exactly "true" or "false", e.g. enum:"1,0" or enum:"TRUE,False".
Common situations: Copy-pasting numeric-bool conventions (0/1) from OpenAPI or protobuf enums; capitalizing booleans by habit; forgetting that this parser is stricter than strconv.ParseBool.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- expected boolean
- %s must be one of: %s
- %s has an unsupported boolean value
- Invalid column: {col}
- lark-cli returned a non-object JSON payload
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/8157c387e37136ed.
Report an issue: GitHub.