{"record":{"id":"5a2fd76e67d990ca","repo":"remotion-dev/remotion","slug":"maxretries-cannot-be-negative-but-is-maxretries-5a2fd7","errorCode":null,"errorMessage":"maxRetries cannot be negative but is ${maxRetries}","messagePattern":"maxRetries cannot be negative but is (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/lambda/src/shared/validate-retries.ts","lineNumber":19,"sourceCode":"export function validateMaxRetries(\n\tmaxRetries: unknown,\n): asserts maxRetries is number {\n\tif (typeof maxRetries !== 'number') {\n\t\tthrow new TypeError(\n\t\t\t'maxRetries must be a number, but is ' + JSON.stringify(maxRetries),\n\t\t);\n\t}\n\n\tif (!Number.isFinite(maxRetries)) {\n\t\tthrow new TypeError('maxRetries must be finite, but is ' + maxRetries);\n\t}\n\n\tif (Number.isNaN(maxRetries)) {\n\t\tthrow new TypeError('maxRetries is NaN');\n\t}\n\n\tif (maxRetries < 0) {\n\t\tthrow new TypeError(`maxRetries cannot be negative but is ${maxRetries}`);\n\t}\n\n\tif (maxRetries % 1 !== 0) {\n\t\tthrow new TypeError(\n\t\t\t`maxRetries should be an integer, but is ${maxRetries}.`,\n\t\t);\n\t}\n}\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda/src/shared/validate-retries.ts#L1-L28","documentation":"Thrown by validateMaxRetries() in @remotion/lambda when maxRetries is a real number but negative. maxRetries is the count of retry attempts the Lambda CLI applies to a failing render/still; a negative count is meaningless. Unlike the NaN case, this check is reachable because Number.isFinite(-1) is true.","triggerScenarios":"Passing a negative integer to renderMediaOnLambda()/renderStillOnLambda() maxRetries, or `npx remotion lambda render --max-retries=-1`. Common when the value is computed as a delta that goes negative (e.g. retries = limit - attempts).","commonSituations":"Subtracting from a quota/base to derive retries and underflowing past zero; copying a config where retries was set as 'minus one for the first attempt'; typo in env var.","solutions":["Set maxRetries to 0 if you want no retries, or to a positive integer (typically 1-3).","Clamp computed values: const maxRetries = Math.max(0, computed);","Re-check the source of the negative value; it usually indicates a wrong formula upstream."],"exampleFix":"// before\nconst maxRetries = quota - attemptsMade; // can be negative\n\n// after\nconst maxRetries = Math.max(0, quota - attemptsMade);","handlingStrategy":"validation","validationCode":"const maxRetries = Math.max(0, Number.isFinite(parsed) ? Math.floor(parsed) : DEFAULT_MAX_RETRIES);","typeGuard":"const isNonNegativeInteger = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isFinite(v) && v >= 0 && v % 1 === 0;","tryCatchPattern":null,"preventionTips":["Clamp any computed retry count to >= 0 before passing it.","Use 0 to mean 'no retries' rather than a negative sentinel.","Audit formulas that subtract attempts from a quota for underflow."],"tags":["lambda","validation","max-retries","cli","configuration"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}