{"record":{"id":"310b92df77217569","repo":"remotion-dev/remotion","slug":"maxretries-cannot-be-negative-but-is-maxretries","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/cloudrun/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/cloudrun/src/shared/validate-retries.ts#L1-L28","documentation":"Thrown by validateMaxRetries() when maxRetries is a finite number but is less than 0. Retries cannot be negative, so the validator rejects any negative value after confirming type, finiteness, and non-NaN.","triggerScenarios":"Passing a negative retry count, often the result of subtracting a larger number from a smaller one, or flipping a sign incorrectly.","commonSituations":"Computing retries as a difference (e.g. attempt - maxAttempts) that goes negative; off-by-one in a decrement loop; user input parsed with an erroneous minus sign.","solutions":["Clamp the value to a minimum of 0: Math.max(0, value).","Re-check the arithmetic that produces maxRetries for an inverted subtraction.","Use a literal (0 is valid) when you want to disable retries."],"exampleFix":"// before\nconst maxRetries = current - budget; // can be negative\n\n// after\nconst maxRetries = Math.max(0, current - budget);","handlingStrategy":"validation","validationCode":"if (typeof maxRetries === 'number' && maxRetries < 0) {\n  throw new RangeError(`maxRetries cannot be negative: ${maxRetries}`);\n}","typeGuard":"const isNonNegativeInt = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isInteger(v) && v >= 0;","tryCatchPattern":null,"preventionTips":["Clamp computed retry counts with Math.max(0, value).","Double-check subtraction/difference expressions that derive retries.","Use 0 to explicitly disable retries rather than a negative sentinel."],"tags":["cloudrun","validation","numeric"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}