{"record":{"id":"9fc432478a24c0b8","repo":"denoland/deno","slug":"invalid-arguments","errorCode":null,"errorMessage":"Invalid arguments","messagePattern":"Invalid arguments","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"runtime/subprocess_windows/src/process.rs","lineNumber":530,"sourceCode":"        let err = io::Error::last_os_error();\n        drop(unsafe { Box::from_raw(ptr) });\n        return Poll::Ready(Err(err));\n      }\n      inner.waiting = Some(Waiting {\n        rx,\n        wait_object,\n        tx: ptr,\n      });\n    }\n  }\n}\n\npub fn spawn(options: &SpawnOptions) -> Result<ChildProcess, std::io::Error> {\n  let mut startup = unsafe { mem::zeroed::<STARTUPINFOW>() };\n  let mut info = unsafe { mem::zeroed::<PROCESS_INFORMATION>() };\n\n  if options.file.is_empty() || options.args.is_empty() {\n    return Err(std::io::Error::new(\n      std::io::ErrorKind::InvalidInput,\n      \"Invalid arguments\",\n    ));\n  }\n\n  // Convert file path to UTF-16\n  let application = WCString::new(&options.file);\n\n  // Create environment block if provided\n  let env_saw_path = options.env.have_changed_path();\n  let maybe_env = options.env.capture_if_changed();\n\n  let child_paths = if env_saw_path {\n    if let Some(env) = maybe_env.as_ref() {\n      env.get(&EnvKey::new(\"PATH\")).map(|s| s.as_os_str())\n    } else {\n      None\n    }","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/runtime/subprocess_windows/src/process.rs#L512-L548","documentation":"spawn() validates SpawnOptions before touching CreateProcessW: the executable path (options.file) and the argv vector (options.args) must both be non-empty, because the Windows command line is assembled from at least the program name. An empty program string or empty argv is rejected immediately with ErrorKind::InvalidInput 'Invalid arguments'.","triggerScenarios":"new Deno.Command(\"\") on Windows (empty command string), or any API path such as Node-compat child_process or internal tooling that reaches spawn with an empty argv vector.","commonSituations":"Command name read from an unset env var or missing config field (resolving to an empty string); template strings that trim to empty; CLI wrappers forwarding an optional command that was never provided.","solutions":["Validate the command string is non-empty before constructing Deno.Command","Fix the source of the empty string: required env var, config field, or CLI argument","Fail fast with a clear app-level error or provide a sensible default program"],"exampleFix":"// before\nconst cmd = new Deno.Command(Deno.env.get(\"PAGER\") ?? \"\");\n\n// after\nconst pager = Deno.env.get(\"PAGER\");\nif (!pager) throw new Error(\"PAGER environment variable is required\");\nconst cmd = new Deno.Command(pager);","handlingStrategy":"validation","validationCode":"if (typeof prog !== \"string\" || prog.length === 0) {\n  throw new Error(\"command must be a non-empty string\");\n}\nconst cmd = new Deno.Command(prog);","typeGuard":"const isNonEmptyString = (v: unknown): v is string =>\n  typeof v === \"string\" && v.length > 0;","tryCatchPattern":null,"preventionTips":["Resolve commands from env/config with a required-check helper, not `?? \"\"","Fail fast with a clear app-level message when a command name is missing","Unit-test command construction with empty and missing inputs"],"tags":["windows","subprocess","invalid-arguments","validation"],"backgroundTag":"empty-command-argument","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}