{"record":{"id":"eea157d3d88b66f3","repo":"d2lang/d2","slug":"expected-border-radius-to-be-a-number-greater-or","errorCode":null,"errorMessage":"expected \"border-radius\" to be a number greater or equal to 0","messagePattern":"expected \"border-radius\" to be a number greater or equal to 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2graph/d2graph.go","lineNumber":374,"sourceCode":"\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`)\n\t\t}\n\t\ts.StrokeDash.Value = value\n\tcase \"border-radius\":\n\t\tif s.BorderRadius == nil {\n\t\t\tbreak\n\t\t}\n\t\tf, err := strconv.Atoi(value)\n\t\tif err != nil || (f < 0) {\n\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`)","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2graph/d2graph.go#L356-L392","documentation":"The 'border-radius' style key must parse as a non-negative integer. This error is returned when strconv.Atoi fails (non-numeric input) or the integer is negative. Unlike stroke-width/stroke-dash there is no upper bound.","triggerScenarios":"Setting style 'border-radius' to a negative number (e.g. -4) or a non-integer string (\"round\", \"5px\", \"2.5\").","commonSituations":"D2 authors using CSS shorthand keywords or units, or negative values intended to 'inherit' defaults.","solutions":["Set border-radius to an integer >= 0.","Remove units/keywords and use a plain non-negative integer.","Omit the key entirely instead of using negative values to reset."],"exampleFix":"// before\nx.style.border-radius: -4\n// after\nx.style.border-radius: 0","handlingStrategy":"validation","validationCode":"n, err := strconv.Atoi(v)\nif err != nil || n < 0 {\n    return fmt.Errorf(\"border-radius %q must be an integer >= 0\", v)\n}","typeGuard":"func validBorderRadius(s string) bool { n, err := strconv.Atoi(s); return err == nil && n >= 0 }","tryCatchPattern":"if err := applyStyle(\"border-radius\", value); err != nil {\n    if strings.Contains(err.Error(), \"border-radius\") {\n        value = \"0\" // square corners default\n    }\n}","preventionTips":["Reject negative radius values at input time.","Strip units and keywords before applying.","Remember there is no upper bound, but the value must be a plain integer."],"tags":["validation","d2graph","numeric","style"],"backgroundTag":"invalid-style-value","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}