d2lang/d2 · error
expected "multiple" to be true or false
Error message
expected "multiple" to be true or false
What it means
D2's style-setting code parses the "multiple" style value with strconv.ParseBool; a non-boolean value triggers this error and the style is not applied. The check runs only when s.Multiple is non-nil.
Source
Thrown at d2graph/d2graph.go:401
return errors.New(`expected "shadow" to be true or false`)
}
s.Shadow.Value = value
case "3d":
if s.ThreeDee == nil {
break
}
_, err := strconv.ParseBool(value)
if err != nil {
return errors.New(`expected "3d" to be true or false`)
}
s.ThreeDee.Value = value
case "multiple":
if s.Multiple == nil {
break
}
_, err := strconv.ParseBool(value)
if err != nil {
return errors.New(`expected "multiple" to be true or false`)
}
s.Multiple.Value = value
case "font":
if s.Font == nil {
break
}
if _, ok := d2fonts.D2_FONT_TO_FAMILY[strings.ToLower(value)]; !ok {
return fmt.Errorf(`"%v" is not a valid font in our system`, value)
}
s.Font.Value = strings.ToLower(value)
case "font-size":
if s.FontSize == nil {
break
}
f, err := strconv.Atoi(value)
if err != nil || (f < 8 || f > 100) {
return errors.New(`expected "font-size" to be a number between 8 and 100`)
}View on GitHub (pinned to 0d69dca6f5)
Solutions
- Change the value to "true" or "false" (e.g. `x.multiple: true`).
- Use 1 or 0 as numeric boolean literals.
- Remove the multiple key to keep the default.
- Pre-validate style strings with strconv.ParseBool in the calling code before assignment.
Example fix
// before (D2) x: my shape x.multiple: enabled // after x: my shape x.multiple: true
Defensive patterns
Strategy: validation
Validate before calling
func validStyleBool(v string) bool {
_, err := strconv.ParseBool(v)
return err == nil
}
// before applying: if !validStyleBool(multipleVal) { /* fix or reject */ } Type guard
func isParseBoolValue(s string) bool {
switch s {
case "1", "t", "T", "TRUE", "true", "True", "0", "f", "F", "FALSE", "false", "False":
return true
}
return false
} Try / catch
if err := obj.SetStyle("multiple", val); err != nil {
if strings.Contains(err.Error(), `"multiple" to be true or false`) {
// fallback: disable effect
val = "false"
}
} Prevention
- Use true/false or 1/0 for the multiple style key.
- Normalize descriptive inputs (enabled/disabled) to booleans before applying.
- Validate boolean style values in CI linting.
- Omit the key entirely when the default behavior is desired.
When it happens
Trigger: Setting style key "multiple" (for multiple layering effect) to anything strconv.ParseBool rejects, e.g. `x.multiple: yes` or `multiple: enabled`.
Common situations: Writing descriptive values like "yes"/"enabled"/"on" for the multiple-outline effect, or templated configs that interpolate non-boolean strings.
Related errors
- expected "shadow" to be true or false
- expected "3d" to be true or false
- expected "animated" to be true or false
- expected "bold" to be true or false
- expected "italic" to be true or false
AI-assisted analysis of d2lang/d2@0d69dca6f5 (2026-08-31).
Data as JSON: /api/errors/b1ce244ed4264948.
Report an issue: GitHub.