{"record":{"id":"428dc5bbe87706a4","repo":"lovell/sharp","slug":"unsupported-input-input-of-type-typeof-inpu","errorCode":null,"errorMessage":"Unsupported input '${input}' of type ${typeof input}${is.defined(inputOptions) ? ` when also providing options of type ${typeof inputOptions}` : ''}","messagePattern":"Unsupported input '(.+?)' of type (.+?)(.+?)` : ''\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/input.mjs","lineNumber":105,"sourceCode":"      inputDescriptor.buffer = [];\n    }\n  } else if (!is.defined(input) && !is.defined(inputOptions) && is.object(containerOptions) && containerOptions.allowStream) {\n    // Stream without options\n    inputDescriptor.buffer = [];\n  } else if (Array.isArray(input)) {\n    if (input.length > 1) {\n      // Join images together\n      if (!this.options.joining) {\n        this.options.joining = true;\n        this.options.join = input.map(i => this._createInputDescriptor(i));\n      } else {\n        throw new Error('Recursive join is unsupported');\n      }\n    } else {\n      throw new Error('Expected at least two images to join');\n    }\n  } else {\n    throw new Error(`Unsupported input '${input}' of type ${typeof input}${\n      is.defined(inputOptions) ? ` when also providing options of type ${typeof inputOptions}` : ''\n    }`);\n  }\n  if (is.object(inputOptions)) {\n    // failOn\n    if (is.defined(inputOptions.failOn)) {\n      if (is.string(inputOptions.failOn) && is.inArray(inputOptions.failOn, ['none', 'truncated', 'error', 'warning'])) {\n        inputDescriptor.failOn = inputOptions.failOn;\n      } else {\n        throw is.invalidParameterError('failOn', 'one of: none, truncated, error, warning', inputOptions.failOn);\n      }\n    }\n    // autoOrient\n    if (is.defined(inputOptions.autoOrient)) {\n      if (is.bool(inputOptions.autoOrient)) {\n        inputDescriptor.autoOrient = inputOptions.autoOrient;\n      } else {\n        throw is.invalidParameterError('autoOrient', 'boolean', inputOptions.autoOrient);","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/lovell/sharp/blob/56676c69180a32b468123e090f87bfee30539b49/lib/input.mjs#L87-L123","documentation":"The catch-all thrown when the input value does not match any recognized input type (file path string, Buffer, Uint8Array, Stream, ReadStream, or Array for joins). The message interpolates the actual input and its typeof, plus the options type if options were also passed, so the developer can see exactly what was rejected. It is the final else branch after all specific input handlers.","triggerScenarios":"Passing a number, plain object, boolean, function, or BigInt as input: sharp(42), sharp({}), sharp(true). Passing a Promise or async iterable. Passing a URL object instead of a string path.","commonSituations":"Confusing sharp's input contract with another library (e.g., expecting sharp({ src: path })). Passing a parsed URL object rather than url.toString(). Feeding a non-thenable wrapper object from an ORM or file abstraction layer.","solutions":["Pass a recognized input type: string path, Buffer, Uint8Array, Stream, or Array.","Coerce URL objects to strings: sharp(url.toString()) or sharp(url.href).","If reading from an async source, await/resolve it to a Buffer or Stream first, then pass that to sharp.","Read the interpolated message: it tells you both the value and typeof, which pinpoints the mismatch."],"exampleFix":"// before\nsharp({ src: './img.png' })\n\n// after\nsharp('./img.png')","handlingStrategy":"type-guard","validationCode":"function toSharpInput(value) {\n  if (typeof value === 'string') return value;\n  if (Buffer.isBuffer(value) || value instanceof Uint8Array) return value;\n  if (value && typeof value.pipe === 'function') return value;\n  if (Array.isArray(value)) return value;\n  if (value instanceof URL) return value.href;\n  throw new Error(`Unsupported sharp input of type ${typeof value}`);\n}","typeGuard":"function isSupportedSharpInput(v) {\n  return typeof v === 'string' || Buffer.isBuffer(v) || v instanceof Uint8Array ||\n    (v && typeof v.pipe === 'function') || Array.isArray(v);\n}","tryCatchPattern":null,"preventionTips":["Coerce URL objects to strings before passing.","Resolve Promises/async sources to a Buffer or Stream first.","Read the interpolated message to see exactly what type was rejected."],"tags":["input","type-mismatch","validation","unsupported"],"backgroundTag":null,"analyzedSha":"56676c69180a32b468123e090f87bfee30539b49","analyzedAt":"2026-08-13T04:44:31.201Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}