{"record":{"id":"e901cb7176ddc3e2","repo":"vercel/next.js","slug":"server-actions-size-limit-must-be-a-valid-number-o","errorCode":null,"errorMessage":"Server Actions Size Limit must be a valid number or filesize format larger than 1MB: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit","messagePattern":"Server Actions Size Limit must be a valid number or filesize format larger than 1MB: https://nextjs\\.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":965,"sourceCode":"    result.output = 'standalone'\n  }\n\n  if (\n    typeof result.experimental?.serverActions?.bodySizeLimit !== 'undefined'\n  ) {\n    const bytes =\n      require('next/dist/compiled/bytes') as typeof import('next/dist/compiled/bytes')\n    const bodySizeLimit = result.experimental.serverActions.bodySizeLimit\n    let value: number | null\n\n    if (typeof bodySizeLimit === 'number') {\n      value = bodySizeLimit\n    } else {\n      value = bytes.parse(bodySizeLimit)\n    }\n\n    if (value === null || isNaN(value) || value < 1) {\n      throw new Error(\n        'Server Actions Size Limit must be a valid number or filesize format larger than 1MB: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit'\n      )\n    }\n  }\n\n  // Throw if both Middleware and Proxy config are set.\n  if (\n    userConfig.experimental?.proxyClientMaxBodySize !== undefined &&\n    userConfig.experimental?.middlewareClientMaxBodySize !== undefined\n  ) {\n    throw new Error(\n      'Config options `experimental.proxyClientMaxBodySize` and `experimental.middlewareClientMaxBodySize` cannot be set at the same time. Please use `experimental.proxyClientMaxBodySize` instead.'\n    )\n  }\n  if (\n    userConfig.experimental?.proxyPrefetch !== undefined &&\n    userConfig.experimental?.middlewarePrefetch !== undefined\n  ) {","sourceCodeStart":947,"sourceCodeEnd":983,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/config.ts#L947-L983","documentation":"`experimental.serverActions.bodySizeLimit` must parse to a positive number of bytes. The check at config.ts:950-968 uses `bytes.parse` for strings and accepts a number directly; it throws when the result is null, NaN, or less than 1 (byte). The message text mentions 1MB but the actual code floor is 1 byte, so any non-parseable or non-positive value triggers it.","triggerScenarios":"Setting `experimental: { serverActions: { bodySizeLimit: 'abc' } }` (unparseable string), `bodySizeLimit: 0`, `bodySizeLimit: -5`, or `bodySizeLimit: ''`.","commonSituations":"Typos in unit strings (`'1mb'` is valid, `'1 m b'` is not). Copying a config that used a bare number expecting MB but writing 0 or negative. Using a value type bytes.parse does not recognize.","solutions":["Use a valid filesize string supported by the bytes library: `'1mb'`, `'4mb'`, `'2gb'`, or a positive number of bytes.","If you want the default, remove `bodySizeLimit` (default is 1MB).","Verify with `require('bytes').parse(yourValue)` in a scratch script before committing."],"exampleFix":"// before\nmodule.exports = { experimental: { serverActions: { bodySizeLimit: 'abc' } } }\n// after\nmodule.exports = { experimental: { serverActions: { bodySizeLimit: '4mb' } } }","handlingStrategy":"validation","validationCode":"const bytes = require('bytes');\nconst v = config.experimental?.serverActions?.bodySizeLimit;\nif (v !== undefined) {\n  const n = typeof v === 'number' ? v : bytes.parse(v);\n  if (n === null || isNaN(n) || n < 1) throw new Error('invalid bodySizeLimit: ' + v);\n}","typeGuard":"function isValidBodySizeLimit(v: unknown): boolean {\n  if (typeof v === 'number') return v >= 1;\n  if (typeof v === 'string') { const n = require('bytes').parse(v); return typeof n === 'number' && !isNaN(n) && n >= 1; }\n  return false;\n}","tryCatchPattern":null,"preventionTips":["Pre-validate bodySizeLimit with bytes.parse before committing.","Use canonical unit strings like '1mb', '4mb'."],"tags":["config","server-actions","bodysizelimit","validation","next-config"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}