{"record":{"id":"8c199d86c1fc9760","repo":"parallax/jsPDF","slug":"invalid-arguments-passed-to-jspdf-triangle","errorCode":null,"errorMessage":"Invalid arguments passed to jsPDF.triangle","messagePattern":"Invalid arguments passed to jsPDF\\.triangle","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/jspdf.js","lineNumber":4766,"sourceCode":"  API.__private__.triangle = API.triangle = function(\n    x1,\n    y1,\n    x2,\n    y2,\n    x3,\n    y3,\n    style\n  ) {\n    if (\n      isNaN(x1) ||\n      isNaN(y1) ||\n      isNaN(x2) ||\n      isNaN(y2) ||\n      isNaN(x3) ||\n      isNaN(y3) ||\n      !isValidStyle(style)\n    ) {\n      throw new Error(\"Invalid arguments passed to jsPDF.triangle\");\n    }\n    this.lines(\n      [\n        [x2 - x1, y2 - y1], // vector to point 2\n        [x3 - x2, y3 - y2], // vector to point 3\n        [x1 - x3, y1 - y3] // closing vector back to point 1\n      ],\n      x1,\n      y1, // start of path\n      [1, 1],\n      style,\n      true\n    );\n    return this;\n  };\n\n  /**\n   * Adds a rectangle with rounded corners to PDF.","sourceCodeStart":4748,"sourceCodeEnd":4784,"githubUrl":"https://github.com/parallax/jsPDF/blob/a3930ce03a585a26b2c76d12a0f413ce96f6d1a3/src/jspdf.js#L4748-L4784","documentation":"Thrown by jsPDF.triangle when any of the six coordinates (x1,y1,x2,y2,x3,y3) is NaN or the style is invalid. All coordinates must be finite numbers; style must pass isValidStyle (undefined, null, 'S', 'D', 'F', 'DF', 'FD', 'f', 'f*', 'B', 'B*', 'n').","triggerScenarios":"Calling triangle() with a missing vertex coordinate, a non-numeric value, or an unsupported style such as 'stroke', 'outline', or a number.","commonSituations":"Vertex data sourced from an object with missing properties; friendly style names used instead of PDF codes; passing only five coordinates by mistake.","solutions":["Pass six finite numeric coordinates plus a valid style code.","Map 'stroke'/'fill' to 'S'/'F' (or 'DF' for both) in your wrapper.","Default or validate each vertex property before calling."],"exampleFix":"// before\npdf.triangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, 'stroke'); // invalid style\n// after\npdf.triangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, 'S');","handlingStrategy":"validation","validationCode":"const VALID_STYLES = [undefined, null, 'S','D','F','DF','FD','f','f*','B','B*','n'];\nfunction safeTriangle(doc, x1,y1,x2,y2,x3,y3, style) {\n  if (![x1,y1,x2,y2,x3,y3].every(Number.isFinite)) throw new Error('all vertices must be finite');\n  return doc.triangle(x1,y1,x2,y2,x3,y3, 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":["Validate all six vertex coordinates before calling.","Use PDF operator codes for style.","Default each vertex property in your data layer."],"tags":["validation","shapes","triangle","style","api"],"backgroundTag":null,"analyzedSha":"a3930ce03a585a26b2c76d12a0f413ce96f6d1a3","analyzedAt":"2026-08-13T05:33:39.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}