{"record":{"id":"fd3db2a14b64d5c2","repo":"denoland/deno","slug":"invalid-value-v-for-flag-host-and-port","errorCode":null,"errorMessage":"invalid value '{v}' for '{flag}=<HOST_AND_PORT>': {e}","messagePattern":"invalid value '(.+?)' for '(.+?)=<HOST_AND_PORT>': (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"libs/dcore/src/main.rs","lineNumber":180,"sourceCode":"  strace_ops_summary: bool,\n  v8_flags: Vec<String>,\n}\n\nimpl Args {\n  /// Returns `Ok(None)` when `--help` was requested (usage already printed).\n  fn parse(\n    args: impl IntoIterator<Item = String>,\n  ) -> Result<Option<Self>, Error> {\n    let mut out = Args::default();\n    let mut file_path: Option<String> = None;\n    let mut seen_inspect_flag: Option<&'static str> = None;\n\n    // `--inspect*` takes its value only via `=` (clap's `require_equals`), so\n    // `--inspect 1.2.3.4:9229` treats the address as the positional argument.\n    let parse_addr = |flag: &str, value: Option<&str>| match value {\n      None => Ok(None),\n      Some(v) => v.parse::<SocketAddr>().map(Some).map_err(|e| {\n        anyhow::anyhow!(\"invalid value '{v}' for '{flag}=<HOST_AND_PORT>': {e}\")\n      }),\n    };\n\n    for arg in args {\n      let (name, value) = match arg.split_once('=') {\n        Some((name, value)) => (name, Some(value)),\n        None => (arg.as_str(), None),\n      };\n      match name {\n        \"-h\" | \"--help\" => {\n          println!(\"{USAGE}\");\n          return Ok(None);\n        }\n        \"--inspect\" | \"--inspect-brk\" | \"--inspect-wait\" => {\n          if let Some(previous) = seen_inspect_flag {\n            bail!(\"the argument '{previous}' cannot be used with '{name}'\");\n          }\n          seen_inspect_flag = Some(match name {","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/libs/dcore/src/main.rs#L162-L198","documentation":"The dcore binary parses --inspect/--inspect-brk style flags whose value must arrive via '=' (require_equals) and must parse as a Rust SocketAddr: an IP literal plus port, e.g. 127.0.0.1:9229 or [::1]:9229 or 0.0.0.0:9222. Hostnames like localhost, bare ports like 9229, or malformed addresses fail with this error naming the flag and the parse failure.","triggerScenarios":"Launching with --inspect=localhost:9229 (hostname is not an IP literal); --inspect=9229 (missing host part); --inspect=[::1:9229 (bad IPv6 brackets); passing the address as a separate token (--inspect 127.0.0.1:9229) which this parser reads as a positional arg rather than this error, but combined forms like --inspect=:9229 hit it.","commonSituations":"Node muscle memory (--inspect=localhost:9229 is common in Node docs/tooling); CI debug configs written for other runtimes; copy-pasted launch.json/IDE debug configurations; scripts that template the flag with an empty host variable.","solutions":["Use an IP literal: --inspect=127.0.0.1:9229 (or 0.0.0.0:9229 to accept remote connections)","Use plain --inspect or --inspect-brk with no value to get the default address","Keep the value attached with '=' — this parser does not accept --inspect 127.0.0.1:9229 as flag+value","For IPv6, wrap brackets: --inspect=[::1]:9229"],"exampleFix":"# before\n./dcore --inspect=localhost:9229 main.js  # invalid value 'localhost:9229'\n\n# after\n./dcore --inspect=127.0.0.1:9229 main.js","handlingStrategy":"validation","validationCode":"// Validate before spawning dcore\nfunction parseSocketAddr(v: string): { host: string; port: number } | null {\n  const m = /^(\\[([0-9a-fA-F:]+)\\]|(\\d+\\.\\d+\\.\\d+\\.\\d+)):(\\d+)$/.exec(v);\n  if (!m) return null; // rejects 'localhost:9229', '9229', ':9229'\n  const port = Number(m[4]);\n  return port > 0 && port < 65536 ? { host: m[2] ?? m[3], port } : null;\n}\nconst flag = parseSocketAddr(inspectValue)\n  ? `--inspect=${inspectValue}`\n  : \"--inspect\"; // safe default","typeGuard":"// Rust (embedding dcore's arg parser)\nfn is_valid_inspect_addr(v: &str) -> bool {\n    v.parse::<std::net::SocketAddr>().is_ok()\n}","tryCatchPattern":null,"preventionTips":["Always prefer IP literals (127.0.0.1:9229) over hostnames in --inspect values","Attach the value with '='; this parser ignores space-separated values","Centralize debugger flags in one launch helper that validates the address format"],"tags":["cli","inspect","debugging","flag-parsing","socket-address","startup"],"backgroundTag":"invalid-cli-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"}