{"record":{"id":"22a46fab54e0c6e1","repo":"d2lang/d2","slug":"expected-bold-to-be-true-or-false","errorCode":null,"errorMessage":"expected \"bold\" to be true or false","messagePattern":"expected \"bold\" to be true or false","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2graph/d2graph.go","lineNumber":444,"sourceCode":"\t\t\treturn errors.New(`expected \"font-color\" to be a valid named color (\"orange\"), a hex code (\"#f0ff3a\"), or a gradient (\"linear-gradient(red, blue)\")`)\n\t\t}\n\t\ts.FontColor.Value = value\n\tcase \"animated\":\n\t\tif s.Animated == 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 \"animated\" to be true or false`)\n\t\t}\n\t\ts.Animated.Value = value\n\tcase \"bold\":\n\t\tif s.Bold == 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 \"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`)","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2graph/d2graph.go#L426-L462","documentation":"D2's style-setting code parses the \"bold\" style value with strconv.ParseBool; non-boolean values return this error and the style is not applied. Only runs when s.Bold is non-nil.","triggerScenarios":"Setting style key \"bold\" to a value strconv.ParseBool rejects, e.g. `x.bold: yes`, `bold: on`, or `bold: strong`.","commonSituations":"Typing \"yes\"/\"on\"/\"strong\" for bold text, or YAML/JSON configs using language-specific truthy keywords that D2 does not accept.","solutions":["Change the value to \"true\" or \"false\" (e.g. `x.bold: true`).","Use 1 or 0 as accepted boolean numerics.","Remove the bold key to keep the default weight.","Validate style maps with strconv.ParseBool before assignment."],"exampleFix":"// before (D2)\nx: my shape\nx.bold: strong\n// after\nx: my shape\nx.bold: 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(boldVal) { /* 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(\"bold\", val); err != nil {\n\tif strings.Contains(err.Error(), `\"bold\" to be true or false`) {\n\t\t// fallback: default weight\n\t\tval = \"false\"\n\t}\n}","preventionTips":["Use true/false or 1/0 for the bold style key.","Convert strong/yes inputs to booleans before applying.","Validate boolean style keys in a pre-render lint pass.","Omit bold instead of setting it to an invalid value."],"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"}