{"record":{"id":"e4f20464a3666fb1","repo":"transloadit/uppy","slug":"fieldname-must-be-a-string","errorCode":null,"errorMessage":"fieldname must be a string","messagePattern":"fieldname must be a string","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"packages/@uppy/companion/src/server/Uploader.ts","lineNumber":127,"sourceCode":"  // validate HTTP Method (optional)\n  if (options.httpMethod) {\n    if (typeof options.httpMethod !== 'string') {\n      throw new ValidationError('unsupported HTTP METHOD specified')\n    }\n\n    const method = options.httpMethod.toUpperCase()\n    if (method !== 'PUT' && method !== 'POST') {\n      throw new ValidationError('unsupported HTTP METHOD specified')\n    }\n  }\n\n  if (exceedsMaxFileSize(options.companionOptions.maxFileSize, options.size)) {\n    throw new ValidationError('maxFileSize exceeded')\n  }\n\n  // validate fieldname (optional)\n  if (options.fieldname != null && typeof options.fieldname !== 'string') {\n    throw new ValidationError('fieldname must be a string')\n  }\n\n  // validate metadata (optional)\n  if (options.metadata != null && typeof options.metadata !== 'object') {\n    throw new ValidationError('metadata must be an object')\n  }\n\n  // validate headers (optional)\n  if (options.headers != null && typeof options.headers !== 'object') {\n    throw new ValidationError('headers must be an object')\n  }\n\n  // validate protocol (optional)\n  if (\n    options.protocol &&\n    !Object.values(PROTOCOLS).includes(options.protocol)\n  ) {\n    throw new ValidationError('unsupported protocol specified')","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/transloadit/uppy/blob/5d4dedd02a1ac0ae022c75c54aca76558f88e256/packages/@uppy/companion/src/server/Uploader.ts#L109-L145","documentation":"The optional fieldname option (the form field name used for multipart uploads) must be a string when provided. Passing any other type throws a ValidationError.","triggerScenarios":"new Uploader({ fieldname: 123 }) or fieldname: { name: 'file' } — any non-string, non-null value.","commonSituations":"fieldnames pulled from untyped multipart/form-data parsers or request bodies that arrive as non-strings.","solutions":["Pass fieldname as a string, e.g. 'file'","Omit it or pass null to use the default","Coerce with String(fieldname) when sourced from untyped input"],"exampleFix":"// before\nfieldname: req.body.field\n\n// after\nfieldname: typeof req.body.field === 'string' ? req.body.field : undefined","handlingStrategy":"type-guard","validationCode":"if (fieldname != null && typeof fieldname !== 'string') fieldname = String(fieldname)","typeGuard":"const isFieldname = (f: unknown): f is string => typeof f === 'string'","tryCatchPattern":"null","preventionTips":["Coerce form-derived fieldnames to strings"],"tags":["companion","uploader","validation","form-data"],"backgroundTag":"invalid-option-type","analyzedSha":"5d4dedd02a1ac0ae022c75c54aca76558f88e256","analyzedAt":"2026-08-28T12:18:41.267Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}