{"record":{"id":"6f7184438e99395a","repo":"d2lang/d2","slug":"unknown-style-key-s","errorCode":null,"errorMessage":"unknown style key: %s","messagePattern":"unknown style key: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2graph/d2graph.go","lineNumber":492,"sourceCode":"\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}\n\t\ts.TextTransform.Value = value\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown style key: %s\", key)\n\t}\n\n\treturn nil\n}\n\ntype ContainerLevel int\n\nfunc (l ContainerLevel) LabelSize() int {\n\t// Largest to smallest\n\tif l == 1 {\n\t\treturn d2fonts.FONT_SIZE_XXL\n\t} else if l == 2 {\n\t\treturn d2fonts.FONT_SIZE_XL\n\t} else if l == 3 {\n\t\treturn d2fonts.FONT_SIZE_L\n\t}\n\treturn d2fonts.FONT_SIZE_M\n}","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2graph/d2graph.go#L474-L510","documentation":"SetStyle on a d2graph object only recognizes known style keys (fill, stroke, font, text-transform, etc.). An unrecognized key hits the default branch and returns \"unknown style key\" naming the key.","triggerScenarios":"Passing any key that is not in SetStyle's switch — e.g. `style.colour`, `style.bg-color`, or a misspelled known key like `style.storke-width`.","commonSituations":"Typos in .d2 style blocks, using CSS property names instead of D2's keys, or using keys from newer/older D2 versions than the installed binary.","solutions":["Correct the key spelling against D2's documented style keys","Use the D2 equivalent name (e.g. \"stroke-width\" not \"strokeWidth\")","Upgrade D2 if the key was added in a newer version"],"exampleFix":"// before\nx.style.colour: red\n// after\nx.style.fill: red","handlingStrategy":"validation","validationCode":"var knownStyleKeys = map[string]bool{\"fill\":true, \"stroke\":true, \"font\":true, \"font-size\":true, \"text-transform\":true /* ... */}\nif !knownStyleKeys[key] { /* reject before SetStyle */ }","typeGuard":"func knownStyleKey(k string) bool {\n\tswitch k { case \"fill\",\"stroke\",\"stroke-width\",\"fill-pattern\",\"font\",\"font-size\",\"text-transform\",\"border-radius\",\"double-border\", \"shadow\",\"opacity\",\"multiple\",\"animated\",\"link\",\"stroke-dash\",\"bold\",\"italic\",\"underline\",\"font-color\": return true }\n\treturn false\n}","tryCatchPattern":"if err := obj.SetStyle(key, val); err != nil {\n\treturn fmt.Errorf(\"check style key %q against d2 docs: %v\", key, err)\n}","preventionTips":["Verify key names against D2 docs for your installed version","Avoid CSS property naming in style blocks","Upgrade d2 if a key you need is reported unknown"],"tags":["d2","style-validation","unknown-key"],"backgroundTag":"invalid-style-value","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}