{"record":{"id":"832f85661ef4066b","repo":"nodejs/node","slug":"und-err-invalid-arg-832f85","errorCode":"UND_ERR_INVALID_ARG","errorMessage":"invalid opts","messagePattern":"invalid opts","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/api/api-pipeline.js","lineNumber":71,"sourceCode":"  }\n\n  _read () {\n    this[kResume]()\n  }\n\n  _destroy (err, callback) {\n    if (!err && !this._readableState.endEmitted) {\n      err = new RequestAbortedError()\n    }\n\n    callback(err)\n  }\n}\n\nclass PipelineHandler extends AsyncResource {\n  constructor (opts, handler) {\n    if (!opts || typeof opts !== 'object') {\n      throw new InvalidArgumentError('invalid opts')\n    }\n\n    if (typeof handler !== 'function') {\n      throw new InvalidArgumentError('invalid handler')\n    }\n\n    const { signal, method, opaque, onInfo, responseHeaders } = opts\n\n    if (signal && typeof signal.on !== 'function' && typeof signal.addEventListener !== 'function') {\n      throw new InvalidArgumentError('signal must be an EventEmitter or EventTarget')\n    }\n\n    if (method === 'CONNECT') {\n      throw new InvalidArgumentError('invalid method')\n    }\n\n    if (onInfo && typeof onInfo !== 'function') {\n      throw new InvalidArgumentError('invalid onInfo callback')","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/api/api-pipeline.js#L53-L89","documentation":"Thrown by undici's PipelineHandler constructor when the opts argument to pipeline() is null, undefined, or not an object. pipeline() streams a request body and response body through a user handler. Code is UND_ERR_INVALID_ARG.","triggerScenarios":"Calling undici.pipeline(url, null, handler) or pipeline(url, undefined, handler) — passing a non-object where the options object is required.","commonSituations":"Omitting opts but keeping the position (call signature confusion); passing a string/object that is actually the handler; conditionally building opts that resolved to undefined.","solutions":["Pass a plain options object even if empty: pipeline(url, {}, handler).","Verify opts is built and defined before the call.","Remember pipeline signature is (url, opts, handler) — three args."],"exampleFix":"// before\nundici.pipeline(url, undefined, handler)\n// after\nundici.pipeline(url, {}, handler)","handlingStrategy":"type-guard","validationCode":"function withOpts(o) { return o && typeof o === 'object' ? o : {} }","typeGuard":"function isOptsObject(o: unknown): o is Record<string, unknown> { return !!o && typeof o === 'object' }","tryCatchPattern":"try { undici.pipeline(url, opts, handler) }\ncatch (err) {\n  if (err.code === 'UND_ERR_INVALID_ARG' && /invalid opts/.test(err.message)) {\n    throw new TypeError('pipeline opts must be an object')\n  }\n  throw err\n}","preventionTips":["Pass {} when no options are needed.","Remember pipeline signature: (url, opts, handler).","Default opts to {} at the call boundary."],"tags":["undici","pipeline","stream","validation","argument"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}