transloadit/uppy · error · ValidationError

unsupported HTTP METHOD specified

Error message

unsupported HTTP METHOD specified

What it means

Uploader.validateOptions checks the optional httpMethod and rejects it when it's not a string. Only 'PUT' and 'POST' (case-insensitive) are supported for uploading files to a destination URL.

Source

Thrown at packages/@uppy/companion/src/server/Uploader.ts:112

  extraData?: UploadExtraData | undefined
}

function exceedsMaxFileSize(
  maxFileSize: number | undefined,
  size: number | undefined,
): boolean {
  return maxFileSize !== undefined && size !== undefined && size > maxFileSize
}

export class ValidationError extends Error {
  override name = 'ValidationError'
}

function validateOptions(options: UploaderOptions): void {
  // validate HTTP Method (optional)
  if (options.httpMethod) {
    if (typeof options.httpMethod !== 'string') {
      throw new ValidationError('unsupported HTTP METHOD specified')
    }

    const method = options.httpMethod.toUpperCase()
    if (method !== 'PUT' && method !== 'POST') {
      throw new ValidationError('unsupported HTTP METHOD specified')
    }
  }

  if (exceedsMaxFileSize(options.companionOptions.maxFileSize, options.size)) {
    throw new ValidationError('maxFileSize exceeded')
  }

  // validate fieldname (optional)
  if (options.fieldname != null && typeof options.fieldname !== 'string') {
    throw new ValidationError('fieldname must be a string')
  }

  // validate metadata (optional)

View on GitHub (pinned to 5d4dedd02a)

Solutions

  1. Pass httpMethod as a string: 'PUT' or 'POST'
  2. Omit httpMethod entirely to use the default
  3. Validate/coerce user-supplied methods before constructing Uploader

Example fix

// before
new Uploader({ httpMethod: 123, ... })

// after
new Uploader({ httpMethod: 'PUT', ... })
Defensive patterns

Strategy: type-guard

Validate before calling

if (httpMethod != null && typeof httpMethod !== 'string') throw new TypeError('httpMethod must be a string')

Type guard

const isMethod = (m: unknown): m is string => typeof m === 'string' && ['PUT', 'POST'].includes(m.toUpperCase())

Try / catch

null

Prevention

When it happens

Trigger: Constructing new Uploader({ httpMethod: 123 }) or any non-string value (null is treated as 'not provided' only when omitted; a provided non-string throws).

Common situations: Passing method from untyped request bodies or env vars that end up as numbers/objects; typos in config files.

Related errors


AI-assisted analysis of transloadit/uppy@5d4dedd02a (2026-08-28). Data as JSON: /api/errors/47537cbb6818b098. Report an issue: GitHub.