{"record":{"id":"7d4bc40b2781f41c","repo":"cube-js/cube","slug":"value-input-is-not-valid-for-envname-shou-7d4bc4","errorCode":null,"errorMessage":"Value \"${input}\" is not valid for ${envName}. Should be lower or equal than 65535.","messagePattern":"Value \"(.+?)\" is not valid for (.+?)\\. Should be lower or equal than 65535\\.","errorType":"validation","errorClass":"InvalidConfiguration","httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-shared/src/env.ts","lineNumber":69,"sourceCode":"        return parseInt(input.slice(0, -2), 10) * 1024 * 1024;\n      case 'gb':\n        return parseInt(input.slice(0, -2), 10) * 1024 * 1024 * 1024;\n      default: {\n        throw new InvalidConfiguration(envName, input, description);\n      }\n    }\n  }\n\n  throw new InvalidConfiguration(envName, input, description);\n}\n\nexport function asPortNumber(input: number, envName: string) {\n  if (input < 0) {\n    throw new InvalidConfiguration(envName, input, 'Should be a positive integer.');\n  }\n\n  if (input > 65535) {\n    throw new InvalidConfiguration(envName, input, 'Should be lower or equal than 65535.');\n  }\n\n  return input;\n}\n\n/**\n * Determines whether multiple data sources were declared or not.\n */\nfunction isMultipleDataSources(): boolean {\n  // eslint-disable-next-line no-use-before-define\n  return getEnv('dataSources').length > 0;\n}\n\n/**\n * Returns the specified data source if assertions are passed, throws\n * an error otherwise.\n * @param dataSource The data source to assert.\n */","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-shared/src/env.ts#L51-L87","documentation":"asPortNumber throws InvalidConfiguration when the port value exceeds 65535, the maximum TCP/UDP port number. Cube validates port env vars eagerly so startup fails with a clear message instead of a later bind error. Callers include asPortOrSocket and asFalseOrPort.","triggerScenarios":"Setting a port env var (e.g. CUBEJS_PORT, CUBEJS_SQL_PORT) to a number above 65535, such as 65536 or 80800.","commonSituations":"Digit transposition or an extra digit typed in .env; confusing byte-size values with ports; copy-pasting values between differently-named variables.","solutions":["Set the env var to an integer in the range 0-65535 (e.g. 4000).","If you intended a large number as a size or count, put it in the correct env var for that purpose.","Double-check the digits in the .env value for typos."],"exampleFix":"// before (.env)\nCUBEJS_PORT=655360\n\n// after (.env)\nCUBEJS_PORT=65536 is invalid; use:\nCUBEJS_PORT=4000","handlingStrategy":"validation","validationCode":"const raw = Number(process.env.CUBEJS_PORT);\nif (process.env.CUBEJS_PORT !== undefined && (raw > 65535 || !Number.isInteger(raw))) {\n  throw new Error(`CUBEJS_PORT=\"${process.env.CUBEJS_PORT}\" must be an integer <= 65535.`);\n}","typeGuard":"function isValidPort(v: unknown): v is number {\n  return typeof v === 'number' && Number.isInteger(v) && v >= 0 && v <= 65535;\n}","tryCatchPattern":"try {\n  startCubeServer();\n} catch (e) {\n  if (e instanceof InvalidConfiguration && e.message.includes('65535')) {\n    console.error('Port exceeds 65535; correct the value in your .env.');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Verify port digits for typos (extra digit -> 655360 instead of 6553).","Never copy large numeric values (sizes, counts) into port variables.","Clamp or reject ports > 65535 in your deployment config validation.","Document valid port ranges next to each port env var in your ops runbook."],"tags":["configuration","env-var","port","validation"],"backgroundTag":"invalid-env-value","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}