{"record":{"id":"e311a47101f87d0d","repo":"trekhleb/javascript-algorithms","slug":"invalid-matrix-format","errorCode":null,"errorMessage":"Invalid matrix format","messagePattern":"Invalid matrix format","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/algorithms/math/matrix/Matrix.js","lineNumber":36,"sourceCode":"const validateType = (m) => {\n  if (\n    !m\n    || !Array.isArray(m)\n    || !Array.isArray(m[0])\n  ) {\n    throw new Error('Invalid matrix format');\n  }\n};","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/src/algorithms/math/matrix/Matrix.js#L18-L54","documentation":"Error \"Invalid matrix format\" thrown in trekhleb/javascript-algorithms.","triggerScenarios":"A matrix helper that calls validateType receives a value m that is falsy, is not an array, or whose first element m[0] is not an array — e.g. a number, a flat 1D array, or undefined.","commonSituations":"Passing a flat array, scalar, null, or non-array value to matrix functions such as dot, t, add, mul, or sub.","solutions":["Pass an array of arrays (or deeper nested arrays); the first element must itself be an array.","Guard inputs with Array.isArray checks before calling matrix operations.","Build matrices with the provided helpers (zeros / generate) instead of ad-hoc values."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"85293e3e2b88f4d2ce330d956b139cf628aa1e82","analyzedAt":"2026-08-24T05:59:10.417Z","schemaVersion":2},"datasetVersion":"2026-08-24T07:17:09.176Z"}