{"record":{"id":"0af83dda6fe677b7","repo":"twentyhq/twenty","slug":"workspace-count-limit-must-be-a-number","errorCode":null,"errorMessage":"Workspace count limit must be a number","messagePattern":"Workspace count limit must be a number","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts","lineNumber":99,"sourceCode":"    description:\n      'Start from a specific workspace id. Workspaces are processed in ascending order of id.',\n    required: false,\n  })\n  parseStartFromWorkspaceId(val: string): string {\n    return val;\n  }\n\n  @Option({\n    flags: '--workspace-count-limit [count]',\n    description:\n      'Limit the number of workspaces to process. Workspaces are processed in ascending order of id.',\n    required: false,\n  })\n  parseWorkspaceCountLimit(val: string): number {\n    const limit = parseInt(val);\n\n    if (isNaN(limit)) {\n      throw new Error('Workspace count limit must be a number');\n    }\n\n    if (limit <= 0) {\n      throw new Error('Workspace count limit must be greater than 0');\n    }\n\n    return limit;\n  }\n\n  override async run(\n    _passedParams: string[],\n    options: RawUpgradeCommandOptions,\n  ): Promise<void> {\n    if (options.verbose) {\n      this.logger = new CommandLogger({\n        verbose: true,\n        constructorName: this.constructor.name,\n      });","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts#L81-L117","documentation":"Thrown by the CLI option parser for the `--workspace-count-limit` flag on the upgrade command. The parser runs parseInt(val); if the result is NaN it rejects the input before the command body runs. This is a commander-style @Option decorator's parse hook, so the throw surfaces as a CLI usage error during argument binding.","triggerScenarios":"Invoking the upgrade command with `--workspace-count-limit` set to a non-numeric string: empty string, alphabetic text (e.g. `--workspace-count-limit all`), a flag with no value where the shell passes `undefined`, or a value with trailing characters parseInt cannot parse to a finite number from the start.","commonSituations":"Operator typos (passing `--workspace-count-limit=10x`), scripting mistakes that interpolate an empty variable (`--workspace-count-limit $COUNT` when COUNT is unset → shell drops the arg or passes empty), or confusion with another flag's value format. Note parseInt('10x') === 10 so trailing junk after a leading number will NOT trip this — only fully non-numeric prefixes do.","solutions":["Pass a plain positive integer: `--workspace-count-limit 50`.","If scripting, default unset variables: `--workspace-count-limit ${COUNT:-0}` is wrong (hits the <=0 guard); instead omit the flag entirely when unset.","Validate the value in your wrapper script with a numeric check before forwarding it to the CLI."],"exampleFix":"# before\nnpx nx run twenty-server:database:migrate:prod -- --workspace-count-limit all\n# after\nnpx nx run twenty-server:database:migrate:prod -- --workspace-count-limit 50","handlingStrategy":"validation","validationCode":"function parseWorkspaceCountLimitSafe(val: string | undefined): number | undefined {\n  if (val == null || val === '') return undefined; // flag omitted\n  if (!/^-?\\d+$/.test(val)) {\n    throw new Error(`--workspace-count-limit must be an integer, got: ${val}`);\n  }\n  return parseInt(val, 10);\n}","typeGuard":"function isPositiveIntegerString(val: string): boolean {\n  return /^\\d+$/.test(val) && parseInt(val, 10) > 0;\n}","tryCatchPattern":"try {\n  await upgrade.run([], options);\n} catch (err) {\n  if (err instanceof Error && err.message === 'Workspace count limit must be a number') {\n  console.error('Usage: --workspace-count-limit <positive-integer>, or omit to process all workspaces');\n  process.exit(2);\n  }\n  throw err;\n}","preventionTips":["In wrapper scripts, validate the value is numeric before forwarding to the CLI.","Treat an unset limit as 'all workspaces' by omitting the flag rather than passing a placeholder.","Document the flag in your runbook with a concrete example value."],"tags":["cli","argument-validation","upgrade-command"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}