{"record":{"id":"b1ce244ed4264948","repo":"d2lang/d2","slug":"expected-multiple-to-be-true-or-false","errorCode":null,"errorMessage":"expected \"multiple\" to be true or false","messagePattern":"expected \"multiple\" to be true or false","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2graph/d2graph.go","lineNumber":401,"sourceCode":"\t\t\treturn errors.New(`expected \"shadow\" to be true or false`)\n\t\t}\n\t\ts.Shadow.Value = value\n\tcase \"3d\":\n\t\tif s.ThreeDee == nil {\n\t\t\tbreak\n\t\t}\n\t\t_, err := strconv.ParseBool(value)\n\t\tif err != nil {\n\t\t\treturn errors.New(`expected \"3d\" to be true or false`)\n\t\t}\n\t\ts.ThreeDee.Value = value\n\tcase \"multiple\":\n\t\tif s.Multiple == nil {\n\t\t\tbreak\n\t\t}\n\t\t_, err := strconv.ParseBool(value)\n\t\tif err != nil {\n\t\t\treturn errors.New(`expected \"multiple\" to be true or false`)\n\t\t}\n\t\ts.Multiple.Value = value\n\tcase \"font\":\n\t\tif s.Font == nil {\n\t\t\tbreak\n\t\t}\n\t\tif _, ok := d2fonts.D2_FONT_TO_FAMILY[strings.ToLower(value)]; !ok {\n\t\t\treturn fmt.Errorf(`\"%v\" is not a valid font in our system`, value)\n\t\t}\n\t\ts.Font.Value = strings.ToLower(value)\n\tcase \"font-size\":\n\t\tif s.FontSize == nil {\n\t\t\tbreak\n\t\t}\n\t\tf, err := strconv.Atoi(value)\n\t\tif err != nil || (f < 8 || f > 100) {\n\t\t\treturn errors.New(`expected \"font-size\" to be a number between 8 and 100`)\n\t\t}","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2graph/d2graph.go#L383-L419","documentation":"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.","triggerScenarios":"Setting style key \"multiple\" (for multiple layering effect) to anything strconv.ParseBool rejects, e.g. `x.multiple: yes` or `multiple: enabled`.","commonSituations":"Writing descriptive values like \"yes\"/\"enabled\"/\"on\" for the multiple-outline effect, or templated configs that interpolate non-boolean strings.","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."],"exampleFix":"// before (D2)\nx: my shape\nx.multiple: enabled\n// after\nx: my shape\nx.multiple: true","handlingStrategy":"validation","validationCode":"func validStyleBool(v string) bool {\n\t_, err := strconv.ParseBool(v)\n\treturn err == nil\n}\n// before applying: if !validStyleBool(multipleVal) { /* fix or reject */ }","typeGuard":"func isParseBoolValue(s string) bool {\n\tswitch s {\n\tcase \"1\", \"t\", \"T\", \"TRUE\", \"true\", \"True\", \"0\", \"f\", \"F\", \"FALSE\", \"false\", \"False\":\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":"if err := obj.SetStyle(\"multiple\", val); err != nil {\n\tif strings.Contains(err.Error(), `\"multiple\" to be true or false`) {\n\t\t// fallback: disable effect\n\t\tval = \"false\"\n\t}\n}","preventionTips":["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."],"tags":["d2","style-validation","boolean-parsing","strconv"],"backgroundTag":"invalid-boolean-style-value","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}