{"record":{"id":"3b83a6c860fcea0f","repo":"d2lang/d2","slug":"expected-3d-to-be-true-or-false","errorCode":null,"errorMessage":"expected \"3d\" to be true or false","messagePattern":"expected \"3d\" to be true or false","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2graph/d2graph.go","lineNumber":392,"sourceCode":"\t\t\treturn errors.New(`expected \"border-radius\" to be a number greater or equal to 0`)\n\t\t}\n\t\ts.BorderRadius.Value = value\n\tcase \"shadow\":\n\t\tif s.Shadow == 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 \"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}","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2graph/d2graph.go#L374-L410","documentation":"D2's style-setting code parses the \"3d\" style value with strconv.ParseBool and returns this error when the value is not a boolean literal. s.ThreeDee is only validated when it is non-nil (style explicitly marked as set).","triggerScenarios":"Setting style key \"3d\" to a value strconv.ParseBool rejects, e.g. `x.3d: yes`, `3d: on`, or `3d: 2` in a D2 diagram or via the programmatic style setter.","commonSituations":"Users type \"yes\"/\"on\" instead of \"true\" for the 3D look, or copy boolean values from YAML/JSON configs that use language-specific truthy keywords.","solutions":["Change the 3d value to \"true\" or \"false\" (e.g. `x.3d: true`).","Use 1 or 0 as accepted numeric boolean literals.","Remove the 3d key if the default (disabled) look is fine.","Validate user-supplied style maps against ParseBool before passing them to the library."],"exampleFix":"// before (D2)\nx: my shape\nx.3d: on\n// after\nx: my shape\nx.3d: 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(threeDVal) { /* 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(\"3d\", val); err != nil {\n\tif strings.Contains(err.Error(), `\"3d\" to be true or false`) {\n\t\t// fallback: disable 3d\n\t\tval = \"false\"\n\t}\n}","preventionTips":["Use true/false or 1/0 for the 3d style key.","Convert yes/on/off from user config to canonical booleans before applying.","Add a lint step validating boolean style keys in CI.","Unset 3d keys are ignored — remove them instead of setting junk values."],"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"}