{"record":{"id":"684a37981401e366","repo":"mozilla/pdf.js","slug":"invalid-partialmsg","errorCode":null,"errorMessage":"Invalid ${partialMsg}","messagePattern":"Invalid (.+?)","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/evaluator.js","lineNumber":5439,"sourceCode":"              argsLength++;\n            }\n          }\n\n          if (argsLength < numArgs) {\n            const partialMsg =\n              `command ${cmd}: expected ${numArgs} args, ` +\n              `but received ${argsLength} args.`;\n\n            // Incomplete path operators, in particular, can result in fairly\n            // chaotic rendering artifacts. Hence the following heuristics is\n            // used to error, rather than just warn, once a number of invalid\n            // path operators have been encountered (fixes bug1443140.pdf).\n            if (\n              this._isPathOp &&\n              ++this._numInvalidPathOPS >\n                EvaluatorPreprocessor.MAX_INVALID_PATH_OPS\n            ) {\n              throw new FormatError(`Invalid ${partialMsg}`);\n            }\n            // If we receive too few arguments, it's not possible to execute\n            // the command, hence we skip the command.\n            warn(`Skipping ${partialMsg}`);\n            if (args !== null) {\n              args.length = 0;\n            }\n            continue;\n          }\n        } else if (argsLength > numArgs) {\n          info(\n            `Command ${cmd}: expected [0, ${numArgs}] args, ` +\n              `but received ${argsLength} args.`\n          );\n        }\n\n        // TODO figure out how to type-check vararg functions\n        this.preprocessCommand(fn, args);","sourceCodeStart":5421,"sourceCodeEnd":5457,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/evaluator.js#L5421-L5457","documentation":"Error \"Invalid ${partialMsg}\" thrown in mozilla/pdf.js.","triggerScenarios":"A content stream with many malformed path operators — e.g. repeated 'l' (lineto) tokens missing their coordinate operands, or 'c' (curveto) with fewer than 6 numbers. Once the running _numInvalidPathOPS counter exceeds EvaluatorPreprocessor.MAX_INVALID_PATH_OPS, this FormatError is thrown. Fires during operator-list preprocessing for the page.","commonSituations":"Vector-heavy PDFs from buggy illustration exporters, hand-authored content streams with typos, or PDFs corrupted in their content-stream region. Also seen after OCR/vectorization tools that emit degenerate path data. The 'Invalid' prefix is followed by the partial message naming the offending operator and argument counts.","solutions":["Re-export the PDF from the originating vector/illustration software with corrected path data.","Run the PDF through Ghostscript (gs -sDEVICE=pdfwrite) which re-flattens and normalizes content streams.","Use stopAtErrors: false (default) — but note this specific check throws regardless once the threshold is exceeded; isolate the page with per-page try/catch instead.","If authoring content streams, validate operator arity against the PDF spec Table A.1 before writing."],"exampleFix":"// before\nawait page.render({ canvasContext, viewport }); // throws after threshold\n\n// after\ntry {\n  await page.render({ canvasContext, viewport });\n} catch (e) {\n  if (/Invalid command/.test(e.message)) {\n    console.warn('Page content stream corrupt, skipping render');\n  } else throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await page.render({ canvasContext, viewport });\n} catch (e) {\n  if (e.name === 'FormatError' && /Invalid command.*expected.*args/.test(e.message)) {\n    // too many malformed path operators — skip this page\n  } else throw e;\n}","preventionTips":["Re-export vector-heavy PDFs from the source illustration software with corrected path data.","Run Ghostscript to re-flatten and normalize content streams.","Validate operator arity against PDF spec Table A.1 when authoring content streams."],"tags":["pdf","content-stream","path-operators","preprocessor","format-error"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}