{"record":{"id":"c2fba13585c5434e","repo":"d2lang/d2","slug":"expected-fill-pattern-to-be-one-of-s","errorCode":null,"errorMessage":"expected \"fill-pattern\" to be one of: %s","messagePattern":"expected \"fill-pattern\" to be one of: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2graph/d2graph.go","lineNumber":347,"sourceCode":"\t\t}\n\t\tif !color.ValidColor(value) {\n\t\t\treturn errors.New(`expected \"stroke\" to be a valid named color (\"orange\"), a hex code (\"#f0ff3a\"), or a gradient (\"linear-gradient(red, blue)\")`)\n\t\t}\n\t\ts.Stroke.Value = value\n\tcase \"fill\":\n\t\tif s.Fill == nil {\n\t\t\tbreak\n\t\t}\n\t\tif !color.ValidColor(value) {\n\t\t\treturn errors.New(`expected \"fill\" to be a valid named color (\"orange\"), a hex code (\"#f0ff3a\"), or a gradient (\"linear-gradient(red, blue)\")`)\n\t\t}\n\t\ts.Fill.Value = value\n\tcase \"fill-pattern\":\n\t\tif s.FillPattern == nil {\n\t\t\tbreak\n\t\t}\n\t\tif !go2.Contains(d2ast.FillPatterns, strings.ToLower(value)) {\n\t\t\treturn fmt.Errorf(`expected \"fill-pattern\" to be one of: %s`, strings.Join(d2ast.FillPatterns, \", \"))\n\t\t}\n\t\ts.FillPattern.Value = value\n\tcase \"stroke-width\":\n\t\tif s.StrokeWidth == nil {\n\t\t\tbreak\n\t\t}\n\t\tf, err := strconv.Atoi(value)\n\t\tif err != nil || (f < 0 || f > 15) {\n\t\t\treturn errors.New(`expected \"stroke-width\" to be a number between 0 and 15`)\n\t\t}\n\t\ts.StrokeWidth.Value = value\n\tcase \"stroke-dash\":\n\t\tif s.StrokeDash == nil {\n\t\t\tbreak\n\t\t}\n\t\tf, err := strconv.Atoi(value)\n\t\tif err != nil || (f < 0 || f > 10) {\n\t\t\treturn errors.New(`expected \"stroke-dash\" to be a number between 0 and 10`)","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2graph/d2graph.go#L329-L365","documentation":"The 'fill-pattern' style key must be one of the values in d2ast.FillPatterns (case-insensitive match after strings.ToLower). This error lists the allowed values when the provided value isn't one of them.","triggerScenarios":"Setting style 'fill-pattern' to anything not in d2ast.FillPatterns, e.g. `fill-pattern: hatch` or `fill-pattern: dotted` if not in the list.","commonSituations":"D2 authors guessing pattern names or copying SVG pattern names instead of the D2-recognized ones (e.g. \"dots\", \"lines\", \"grid\" — whichever d2ast.FillPatterns contains).","solutions":["Use one of the values listed in the error message (strings.Join(d2ast.FillPatterns, \", \")).","Check the exact spelling against d2ast.FillPatterns in d2ast.","Remove the fill-pattern key if no pattern is desired."],"exampleFix":"// before\nx.style.fill-pattern: hatch\n// after\nx.style.fill-pattern: dots","handlingStrategy":"validation","validationCode":"if !go2.Contains(d2ast.FillPatterns, strings.ToLower(v)) {\n    return fmt.Errorf(\"fill-pattern %q must be one of: %s\", v, strings.Join(d2ast.FillPatterns, \", \"))\n}","typeGuard":"func validFillPattern(v string) bool { return go2.Contains(d2ast.FillPatterns, strings.ToLower(v)) }","tryCatchPattern":"if err := applyStyle(\"fill-pattern\", value); err != nil {\n    if strings.Contains(err.Error(), \"fill-pattern\") {\n        value = d2ast.FillPatterns[0] // default pattern\n    }\n}","preventionTips":["Derive allowed values from d2ast.FillPatterns instead of hardcoding strings.","Normalize case with strings.ToLower before comparing.","Surface the error's list of valid values in UIs/editors."],"tags":["validation","d2graph","style","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}