cube-js/cube · error · InvalidConfiguration
Value "${value}" is not valid for CUBEJS_MAX_REQUEST_SIZE. M
Error message
Value "${value}" is not valid for CUBEJS_MAX_REQUEST_SIZE. Must be between 100kb and 64mb. What it means
Cube validates CUBEJS_MAX_REQUEST_SIZE and rejects values that convert to fewer than 100KB or more than 64MB, throwing an InvalidConfiguration error. This guards the HTTP request body limit against unusable or unsafe values.
Source
Thrown at packages/cubejs-backend-shared/src/env.ts:235
tls: () => get('CUBEJS_ENABLE_TLS')
.default('false')
.asBoolStrict(),
webSockets: () => get('CUBEJS_WEB_SOCKETS')
.default('false')
.asBoolStrict(),
serverHeadersTimeout: () => get('CUBEJS_SERVER_HEADERS_TIMEOUT')
.asInt(),
serverKeepAliveTimeout: () => get('CUBEJS_SERVER_KEEP_ALIVE_TIMEOUT')
.asInt(),
maxRequestSize: () => {
const value = process.env.CUBEJS_MAX_REQUEST_SIZE || '50mb';
const bytes = convertSizeToBytes(value, 'CUBEJS_MAX_REQUEST_SIZE');
const minBytes = 100 * 1024; // 100kb
const maxBytes = 64 * 1024 * 1024; // 64mb
if (bytes < minBytes || bytes > maxBytes) {
throw new InvalidConfiguration(
'CUBEJS_MAX_REQUEST_SIZE',
value,
'Must be between 100kb and 64mb.'
);
}
return bytes;
},
rollupOnlyMode: () => get('CUBEJS_ROLLUP_ONLY')
.default('false')
.asBoolStrict(),
schemaPath: () => get('CUBEJS_SCHEMA_PATH')
.default('model')
.asString(),
refreshWorkerMode: () => {
const refreshWorkerMode = get('CUBEJS_REFRESH_WORKER').asBool();
if (refreshWorkerMode !== undefined) {
return refreshWorkerMode;View on GitHub (pinned to 7d981676b3)
Solutions
- Set CUBEJS_MAX_REQUEST_SIZE to a value between 100kb and 64mb, e.g. '10mb'.
- Use explicit units (kb/mb) so convertSizeToBytes parses the value correctly.
- If you need a limit above 64mb, front Cube with a proxy (nginx/ALB) that allows larger bodies instead of this env var.
- Verify the value with a quick conversion (e.g. 64 * 1024 * 1024 bytes = 67108864) before deploying.
Example fix
// before CUBEJS_MAX_REQUEST_SIZE=500kb // throws: below 100kb? no, ok; but 50kb would throw CUBEJS_MAX_REQUEST_SIZE=50kb // after CUBEJS_MAX_REQUEST_SIZE=10mb
Defensive patterns
Strategy: validation
Validate before calling
const MAX = 64 * 1024 * 1024, MIN = 100 * 1024;
function parseSize(v) {
const m = /^(\d+)\s*(kb|mb)?$/i.exec(String(v).trim());
if (!m) return null;
const n = +m[1] * (m[2]?.toLowerCase() === 'mb' ? 1024 * 1024 : m[2] ? 1024 : 1);
return n >= MIN && n <= MAX ? n : null;
}
if (process.env.CUBEJS_MAX_REQUEST_SIZE && parseSize(process.env.CUBEJS_MAX_REQUEST_SIZE) === null)
throw new Error('CUBEJS_MAX_REQUEST_SIZE must be between 100kb and 64mb'); Try / catch
try {
startServer();
} catch (e) {
if (String(e.message).includes('CUBEJS_MAX_REQUEST_SIZE')) {
console.error('Fix CUBEJS_MAX_REQUEST_SIZE: use values like 10mb (range 100kb-64mb)');
process.exit(1);
}
throw e;
} Prevention
- Always include explicit kb/mb units.
- Keep the value within 100kb-64mb; enforce larger limits at a reverse proxy instead.
- Validate env files in CI before deploy.
When it happens
Trigger: Setting CUBEJS_MAX_REQUEST_SIZE to a value out of range, e.g. '10kb', '1kb', '100mb', or an empty/invalid string that converts to 0 bytes via convertSizeToBytes.
Common situations: Admins trying to shrink the limit below 100kb for security, or raise it above 64mb for large queries; a unit typo like '64k' instead of '64mb'; whitespace/garbage values.
Understand the failure class
Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.
Related errors
- The ${keyByDataSource('CUBEJS_DB_USE_SELECT_TEST_CONNECTION'
- wrong configuration for environment variable '{}' with '{}'
- wrong configuration for environment variable '{}' with '{}'
- A user-defined contextToApiScopes function returns a wrong s
- Value "${input}" is not valid for ${envName}. ${description}
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/c04cb59e706e8b82.
Report an issue: GitHub.