{"record":{"id":"13814ac5655c9f6e","repo":"parallax/jsPDF","slug":"invalid-arguments-passed-to-jspdf-roundedrect","errorCode":null,"errorMessage":"Invalid arguments passed to jsPDF.roundedRect","messagePattern":"Invalid arguments passed to jsPDF\\.roundedRect","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/jspdf.js","lineNumber":4824,"sourceCode":"  API.__private__.roundedRect = API.roundedRect = function(\n    x,\n    y,\n    w,\n    h,\n    rx,\n    ry,\n    style\n  ) {\n    if (\n      isNaN(x) ||\n      isNaN(y) ||\n      isNaN(w) ||\n      isNaN(h) ||\n      isNaN(rx) ||\n      isNaN(ry) ||\n      !isValidStyle(style)\n    ) {\n      throw new Error(\"Invalid arguments passed to jsPDF.roundedRect\");\n    }\n    var MyArc = (4 / 3) * (Math.SQRT2 - 1);\n\n    rx = Math.min(rx, w * 0.5);\n    ry = Math.min(ry, h * 0.5);\n\n    this.lines(\n      [\n        [w - 2 * rx, 0],\n        [rx * MyArc, 0, rx, ry - ry * MyArc, rx, ry],\n        [0, h - 2 * ry],\n        [0, ry * MyArc, -(rx * MyArc), ry, -rx, ry],\n        [-w + 2 * rx, 0],\n        [-(rx * MyArc), 0, -rx, -(ry * MyArc), -rx, -ry],\n        [0, -h + 2 * ry],\n        [0, -(ry * MyArc), rx * MyArc, -ry, rx, -ry]\n      ],\n      x + rx,","sourceCodeStart":4806,"sourceCodeEnd":4842,"githubUrl":"https://github.com/parallax/jsPDF/blob/a3930ce03a585a26b2c76d12a0f413ce96f6d1a3/src/jspdf.js#L4806-L4842","documentation":"Thrown by jsPDF.roundedRect when x, y, w, h, rx, or ry is NaN or the style is invalid. All six must be finite numbers; style must pass isValidStyle (undefined, null, 'S', 'D', 'F', 'DF', 'FD', 'f', 'f*', 'B', 'B*', 'n'). rx/ry are clamped internally to half the width/height.","triggerScenarios":"Calling roundedRect() with an undefined corner radius, non-numeric dimensions, or an unsupported style string like 'stroke'/'fill' or a numeric style.","commonSituations":"Forgetting rx/ry arguments; using friendly style names; dimensions from optional config that may be undefined; passing a single radius where rx and ry are both required.","solutions":["Provide all six finite numeric values: x, y, w, h, rx, ry.","Use a supported style code ('S', 'F', 'DF') or null/undefined.","Default rx/ry to a sensible corner radius when omitted."],"exampleFix":"// before\npdf.roundedRect(10, 10, 80, 40, 5, 'S'); // missing ry, only 5 args of dims\n// after\npdf.roundedRect(10, 10, 80, 40, 5, 5, 'S');","handlingStrategy":"validation","validationCode":"const VALID_STYLES = [undefined, null, 'S','D','F','DF','FD','f','f*','B','B*','n'];\nfunction safeRoundedRect(doc, x, y, w, h, rx, ry, style) {\n  if (![x,y,w,h,rx,ry].every(Number.isFinite)) throw new Error('all dimensions must be finite');\n  return doc.roundedRect(x, y, w, h, rx, ry, VALID_STYLES.includes(style) ? style : 'S');\n}","typeGuard":"function isValidStyle(s) { return [undefined,null,'S','D','F','DF','FD','f','f*','B','B*','n'].includes(s); }","tryCatchPattern":null,"preventionTips":["Supply both rx and ry explicitly.","Use operator-code styles, not friendly names.","Default corner radii to 0 when omitted."],"tags":["validation","shapes","rounded-rect","style","api"],"backgroundTag":null,"analyzedSha":"a3930ce03a585a26b2c76d12a0f413ce96f6d1a3","analyzedAt":"2026-08-13T05:33:39.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}