{"record":{"id":"bd75b0abfe43dea1","repo":"denoland/deno","slug":"err-missing-args","errorCode":"ERR_MISSING_ARGS","errorMessage":"The \"path\" argument must be specified","messagePattern":"The \"path\" argument must be specified","errorType":"validation","errorClass":"NodeTypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/_fs/_fs_dir.ts","lineNumber":38,"sourceCode":"  SymbolAsyncIterator,\n  SymbolAsyncDispose,\n  SymbolDispose,\n  ArrayIteratorPrototypeNext,\n  SymbolIterator,\n} = primordials;\n\n// Note: unlike `fs.readdir`, `fs.opendir`/`Dir` streams entries in filesystem\n// order and does NOT sort them, matching Node.js (libuv's `uv_fs_readdir`, as\n// opposed to `uv_fs_scandir` which backs `readdir`). Do not add sorting here.\nexport default class Dir {\n  #dirPath: string | Uint8Array;\n  #syncIterator!: Iterator<Deno.DirEntry, undefined> | null;\n  #asyncIterator!: AsyncIterator<Deno.DirEntry, undefined> | null;\n  #closed = false;\n\n  constructor(path: string | Uint8Array) {\n    if (!path) {\n      throw new ERR_MISSING_ARGS(\"path\");\n    }\n    this.#dirPath = path;\n  }\n\n  get path(): string {\n    if (ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, this.#dirPath)) {\n      return new TextDecoder().decode(this.#dirPath);\n    }\n    return this.#dirPath;\n  }\n\n  // deno-lint-ignore no-explicit-any\n  read(callback?: (...args: any[]) => void): Promise<Dirent | null> {\n    return new Promise((resolve, reject) => {\n      if (this.#closed) {\n        const err = new ERR_DIR_CLOSED();\n        if (callback) {\n          callback(err);","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/node/polyfills/_fs/_fs_dir.ts#L20-L56","documentation":"The internal Dir class behind fs.opendir()/fs.opendirSync() throws ERR_MISSING_ARGS when constructed with a falsy path. The public fs.opendir entry points validate the path themselves, so reaching this usually means an empty string or undefined slipped past upstream validation, or the internal class was used directly.","triggerScenarios":"fs.opendir(undefined) or fs.opendir('') on a code path where earlier validation is bypassed; constructing the internal Dir class directly from polyfill internals.","commonSituations":"Path assembled from optional config that is undefined when unset; destructuring that misses/renames the path variable; empty string left after trimming user input.","solutions":["Pass a concrete non-empty path (string, Buffer, or URL)","Validate before the call: if (!path) throw new Error('path required')","Log the offending value at the call site to find which stage of your pipeline lost it"],"exampleFix":"// before\nfs.opendir(dirName, (err, d) => { ... }); // dirName is undefined/''\n\n// after\nif (typeof dirName !== \"string\" || dirName === \"\") {\n  throw new Error(\"opendir requires a non-empty path\");\n}\nfs.opendir(dirName, (err, d) => { ... });","handlingStrategy":"validation","validationCode":"function toNonEmptyPath(p: string | Buffer | URL | undefined): string | Buffer | URL {\n  if (p === undefined || p === null || p === \"\") {\n    throw new Error(\"A non-empty path is required for directory operations\");\n  }\n  return p;\n}\n\nconst dir = fs.opendirSync(toNonEmptyPath(config.dir));","typeGuard":"function isValidDirPath(p: unknown): p is string | Buffer | URL {\n  if (typeof p === \"string\") return p.length > 0;\n  return p instanceof Buffer || p instanceof URL;\n}","tryCatchPattern":null,"preventionTips":["Default optional config paths at load time instead of letting undefined flow into fs calls","Validate user-supplied paths at the API boundary with one shared helper","Log the raw value when path validation fails to locate the pipeline stage that lost it"],"tags":["fs","node-compat","args","validation","opendir"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}