d2lang/d2 · error
expected "double-border" to be true or false
Error message
expected "double-border" to be true or false
What it means
This error comes from applying the `double-border` style to a shape in d2graph. The value assigned to `double-border` must parse as a boolean (true/false); strconv.ParseBool failed, so the value was rejected before being stored on the style.
Source
Thrown at d2graph/d2graph.go:480
return errors.New(`expected "underline" to be true or false`)
}
s.Underline.Value = value
case "filled":
if s.Filled == nil {
break
}
_, err := strconv.ParseBool(value)
if err != nil {
return errors.New(`expected "filled" to be true or false`)
}
s.Filled.Value = value
case "double-border":
if s.DoubleBorder == nil {
break
}
_, err := strconv.ParseBool(value)
if err != nil {
return errors.New(`expected "double-border" to be true or false`)
}
s.DoubleBorder.Value = value
case "text-transform":
if s.TextTransform == nil {
break
}
if !go2.Contains(d2ast.TextTransforms, strings.ToLower(value)) {
return fmt.Errorf(`expected "text-transform" to be one of (%s)`, strings.Join(d2ast.TextTransforms, ", "))
}
s.TextTransform.Value = value
default:
return fmt.Errorf("unknown style key: %s", key)
}
return nil
}
type ContainerLevel intView on GitHub (pinned to 0d69dca6f5)
Solutions
- Change the value to exactly `true` or `false` (also accepted: 1/0, T/F, TRUE/FALSE case-insensitively).
- If the intent was to enable the border, write `style.double-border: true`.
- If the value comes from user input, validate it with strconv.ParseBool before calling Set.
- Check you are not setting a string like "yes"/"on"; d2 does not accept those.
Example fix
// before
style: { double-border: "yes" }
// after
style: { double-border: true } Defensive patterns
Strategy: validation
Validate before calling
func validBool(v string) bool { _, err := strconv.ParseBool(v); return err == nil }
if !validBool(value) { value = "true" } // normalize before Set Type guard
func isD2Bool(v string) bool {
switch strings.ToLower(v) {
case "true", "false", "1", "0", "t", "f": return true
}
return false
} Try / catch
if err := obj.Set(ctx, "style.double-border", val); err != nil && strings.Contains(err.Error(), "double-border") {
// fall back to a boolean default or surface a user-facing validation message
} Prevention
- Always pass literal true/false for double-border.
- Validate user input with strconv.ParseBool before calling Set.
- Don't confuse double-border with other style keys that accept non-boolean values.
When it happens
Trigger: Calling Set on a style map key `double-border` with a value that is not one of 1/t/T/TRUE/true/True/0/f/F/FALSE/false/False, e.g. `shape.Style.DoubleBorder.Value = "yes"` or setting it via a script/API with a non-boolean string.
Common situations: Typing `double-border: yes` or `double-border: on` in a d2 config; passing user-supplied strings from a UI into the style setter; confusing double-border (boolean) with border-radius (number).
Related errors
- expected "opacity" to be a number between 0.0 and 1.0
- expected "stroke" to be a valid named color ("orange"), a he
- expected "fill" to be a valid named color ("orange"), a hex
- expected "fill-pattern" to be one of: %s
- expected "stroke-width" to be a number between 0 and 15
AI-assisted analysis of d2lang/d2@0d69dca6f5 (2026-08-31).
Data as JSON: /api/errors/d3cd6a8b2acedb04.
Report an issue: GitHub.