{"record":{"id":"23a4c5ffefe38c79","repo":"denoland/deno","slug":"unexpected-third-argument-to-deno-bench","errorCode":null,"errorMessage":"Unexpected third argument to Deno.bench()","messagePattern":"Unexpected third argument to Deno\\.bench\\(\\)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"cli/js/40_bench.js","lineNumber":149,"sourceCode":"          \"Unexpected 'name' field in options, bench name is already provided as the first argument\",\n        );\n      }\n      benchDesc = {\n        ...defaults,\n        ...optionsOrFn,\n        fn: maybeFn,\n        name: nameOrFnOrOptions,\n      };\n    }\n  } else if (typeof nameOrFnOrOptions === \"function\") {\n    if (!nameOrFnOrOptions.name) {\n      throw new TypeError(\"The bench function must have a name\");\n    }\n    if (optionsOrFn != undefined) {\n      throw new TypeError(\"Unexpected second argument to Deno.bench()\");\n    }\n    if (maybeFn != undefined) {\n      throw new TypeError(\"Unexpected third argument to Deno.bench()\");\n    }\n    benchDesc = {\n      ...defaults,\n      fn: nameOrFnOrOptions,\n      name: nameOrFnOrOptions.name,\n    };\n  } else {\n    let fn;\n    let name;\n    if (typeof optionsOrFn === \"function\") {\n      fn = optionsOrFn;\n      if (nameOrFnOrOptions.fn != undefined) {\n        throw new TypeError(\n          \"Unexpected 'fn' field in options, bench function is already provided as the second argument\",\n        );\n      }\n      name = nameOrFnOrOptions.name ?? fn.name;\n    } else {","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/js/40_bench.js#L131-L167","documentation":"`install_global_compiled` takes the first element of `InstallFlagsGlobal::module_urls` and errors when the vec is empty. The public CLI grammar requires a module URL, so in practice this is an internal invariant that fires only when install flags are constructed programmatically (embedders, custom CLIs driving deno's install API) with an empty URL list.","triggerScenarios":"Programmatically invoking the global install entry point with `InstallFlagsGlobal { module_urls: vec![], .. }` — e.g. a wrapper tool that builds the install command from user input and drops/empties the URL argument before calling deno.","commonSituations":"Custom package-manager wrappers around deno; scripts that template `deno install -g` invocations and fail to substitute the URL; refactors of deno_lib call sites.","solutions":["Pass the entrypoint module URL (file path, https URL, or npm:/jsr: specifier) in module_urls","Validate the user-supplied URL is non-empty before constructing the install command","If hitting this via the CLI itself, check for a malformed/empty argument (e.g. an unset shell variable expanding to nothing)"],"exampleFix":"# before (empty variable expands to no URL)\ndeno install -g \"$TOOL_URL\"\n# No module URL provided\n\n# after\n: \"${TOOL_URL:?TOOL_URL must be set}\"\ndeno install -g \"$TOOL_URL\"","handlingStrategy":"validation","validationCode":"# Require a non-empty URL before invoking install\n: \"${TOOL_URL:?module URL is required}\"\ndeno install -g \"$TOOL_URL\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fail fast on empty user input with parameter expansions like ${VAR:?}","When embedding deno_lib, assert `!module_urls.is_empty()` before calling install","Log the fully-assembled install command in wrappers to catch dropped arguments"],"tags":["install","missing-argument","internal-invariant","global-install"],"backgroundTag":"missing-required-argument","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}