{"record":{"id":"237df2d5d9df98b5","repo":"d2lang/d2","slug":"expected-underline-to-be-true-or-false","errorCode":null,"errorMessage":"expected \"underline\" to be true or false","messagePattern":"expected \"underline\" to be true or false","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2graph/d2graph.go","lineNumber":462,"sourceCode":"\t\t\treturn errors.New(`expected \"bold\" to be true or false`)\n\t\t}\n\t\ts.Bold.Value = value\n\tcase \"italic\":\n\t\tif s.Italic == 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 \"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`)","sourceCodeStart":444,"sourceCodeEnd":480,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2graph/d2graph.go#L444-L480","documentation":"D2's style-setting code parses the \"underline\" style value with strconv.ParseBool; invalid values return this error and the style is skipped. Applies only when s.Underline is non-nil.","triggerScenarios":"Setting style key \"underline\" to a value strconv.ParseBool rejects, e.g. `x.underline: yes` or `underline: on`.","commonSituations":"Users write \"yes\"/\"on\" for underlined text or reuse CSS-style values like \"underline\"/\"line-through\" instead of booleans.","solutions":["Change the value to \"true\" or \"false\" (e.g. `x.underline: true`).","Use 1 or 0 as accepted boolean numerics.","Remove the underline key to keep default text decoration.","Normalize user input to \"true\"/\"false\" before passing it into the style setter."],"exampleFix":"// before (D2)\nx: my shape\nx.underline: on\n// after\nx: my shape\nx.underline: 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(underlineVal) { /* 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(\"underline\", val); err != nil {\n\tif strings.Contains(err.Error(), `\"underline\" to be true or false`) {\n\t\t// fallback: no underline\n\t\tval = \"false\"\n\t}\n}","preventionTips":["Use true/false or 1/0 for the underline style key.","Do not reuse CSS text-decoration values (underline/line-through) here.","Normalize yes/on inputs to canonical booleans first.","Validate boolean style keys in CI linting."],"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"}