{"record":{"id":"b1dfdb39ba3d6101","repo":"transloadit/uppy","slug":"incorrect-chunksize","errorCode":null,"errorMessage":"incorrect chunkSize","messagePattern":"incorrect chunkSize","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"packages/@uppy/companion/src/server/Uploader.ts","lineNumber":175,"sourceCode":"      if (url == null) return\n      const validatorOpts = { require_protocol: true, require_tld: false }\n      if (!validator.isURL(url, validatorOpts)) {\n        throw new ValidationError('invalid destination url')\n      }\n\n      const allowedUrls = options.companionOptions.uploadUrls\n      if (allowedUrls && !hasMatch(url, allowedUrls)) {\n        throw new ValidationError(\n          'upload destination does not match any allowed destinations',\n        )\n      }\n    }\n\n    ;[options.endpoint, options.uploadUrl].forEach(validateUrl)\n  }\n\n  if (options.chunkSize != null && typeof options.chunkSize !== 'number') {\n    throw new ValidationError('incorrect chunkSize')\n  }\n}\n\nconst states = {\n  idle: 'idle',\n  uploading: 'uploading',\n  paused: 'paused',\n  done: 'done',\n}\n\nexport default class Uploader {\n  static FILE_NAME_PREFIX = 'uppy-file'\n\n  static STORAGE_PREFIX = 'companion'\n\n  storage: Redis | null | undefined\n\n  providerName: string | undefined","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/transloadit/uppy/blob/5d4dedd02a1ac0ae022c75c54aca76558f88e256/packages/@uppy/companion/src/server/Uploader.ts#L157-L193","documentation":"Uploader.validateOptions enforces that options.chunkSize, when present, must be a number. It is intended to be set server-side from Companion's chunkSize config; a non-numeric value (string, boolean, object) throws ValidationError 'incorrect chunkSize'.","triggerScenarios":"Constructing Uploader with chunkSize: '1024' (string) or another non-number type; or a Companion config layer that reads chunkSize from an env var without converting it to a number and passes it through.","commonSituations":"Setting COMPANION_CHUNK_SIZE as an env var (always a string) and having custom code inject it un-parsed; programmatic use of the Uploader class outside the standard reqToOptions path.","solutions":["Pass chunkSize as a number: chunkSize: 1024 (or omit it)","If sourced from an env var, convert with Number.parseInt/Number() and validate before use","Audit custom code that builds Uploader options directly"],"exampleFix":"// before\nnew Uploader({ ..., chunkSize: process.env.CHUNK_SIZE })\n\n// after\nnew Uploader({ ..., chunkSize: Number.parseInt(process.env.CHUNK_SIZE ?? '0', 10) || undefined })","handlingStrategy":"type-guard","validationCode":"if (opts.chunkSize != null && typeof opts.chunkSize !== 'number') {\n  opts.chunkSize = Number(opts.chunkSize)\n}","typeGuard":"const isNumericChunkSize = (v: unknown): v is number => v == null || typeof v === 'number';","tryCatchPattern":null,"preventionTips":["Parse env-sourced chunk sizes with Number() at the config boundary","Type Uploader options with TypeScript so chunkSize is number | undefined"],"tags":["companion","uploader","chunk-size","type-validation"],"backgroundTag":"option-type-mismatch","analyzedSha":"5d4dedd02a1ac0ae022c75c54aca76558f88e256","analyzedAt":"2026-08-28T12:18:41.267Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}