{"record":{"id":"1eb352eb71badfc3","repo":"d2lang/d2","slug":"expected-filled-to-be-true-or-false","errorCode":null,"errorMessage":"expected \"filled\" to be true or false","messagePattern":"expected \"filled\" to be true or false","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2graph/d2graph.go","lineNumber":471,"sourceCode":"\t\t\treturn errors.New(`expected \"italic\" to be true or false`)\n\t\t}\n\t\ts.Italic.Value = value\n\tcase \"underline\":\n\t\tif s.Underline == 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 \"underline\" to be true or false`)\n\t\t}\n\t\ts.Underline.Value = value\n\tcase \"filled\":\n\t\tif s.Filled == 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 \"filled\" to be true or false`)\n\t\t}\n\t\ts.Filled.Value = value\n\tcase \"double-border\":\n\t\tif s.DoubleBorder == 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 \"double-border\" to be true or false`)\n\t\t}\n\t\ts.DoubleBorder.Value = value\n\tcase \"text-transform\":\n\t\tif s.TextTransform == nil {\n\t\t\tbreak\n\t\t}\n\t\tif !go2.Contains(d2ast.TextTransforms, strings.ToLower(value)) {\n\t\t\treturn fmt.Errorf(`expected \"text-transform\" to be one of (%s)`, strings.Join(d2ast.TextTransforms, \", \"))\n\t\t}","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2graph/d2graph.go#L453-L489","documentation":"D2's style-setting code parses the \"filled\" style value with strconv.ParseBool; non-boolean values return this error and the fill is not applied. Runs only when s.Filled is non-nil.","triggerScenarios":"Setting style key \"filled\" to a value strconv.ParseBool rejects, e.g. `x.filled: yes`, `filled: on`, or a color string mistakenly placed in filled (e.g. `filled: green` — use `fill` or `fill-color` for colors).","commonSituations":"Confusing \"filled\" (boolean) with the fill-color style and passing a color, or using \"yes\"/\"on\" truthy words from other config languages.","solutions":["Change the value to \"true\" or \"false\" (e.g. `x.filled: true`).","If you intended a color, use the fill/fill-color style key instead of filled.","Use 1 or 0 as numeric boolean literals.","Pre-validate with strconv.ParseBool before assigning the style."],"exampleFix":"// before (D2)\nx: my shape\nx.filled: green\n// after\nx: my shape\nx.filled: true\nx.fill-color: green","handlingStrategy":"validation","validationCode":"func validStyleBool(v string) bool {\n\t_, err := strconv.ParseBool(v)\n\treturn err == nil\n}\n// before applying: if !validStyleBool(filledVal) { /* 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(\"filled\", val); err != nil {\n\tif strings.Contains(err.Error(), `\"filled\" to be true or false`) {\n\t\t// fallback: default fill, or reroute color to fill-color\n\t\tval = \"false\"\n\t}\n}","preventionTips":["Use true/false or 1/0 for the filled style key.","Route colors to fill/fill-color, not filled.","Normalize yes/on truthy words to booleans before applying.","Validate boolean style values with strconv.ParseBool in a lint pass."],"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"}