denoland/deno · error · anyhow::Error

invalid value ' ' for ' =

Error message

invalid value '{v}' for '{flag}=<HOST_AND_PORT>': {e}

What it means

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.

Solutions

  1. Use an IP literal: --inspect=127.0.0.1:9229 (or 0.0.0.0:9229 to accept remote connections)
  2. Use plain --inspect or --inspect-brk with no value to get the default address
  3. Keep the value attached with '=' — this parser does not accept --inspect 127.0.0.1:9229 as flag+value
  4. For IPv6, wrap brackets: --inspect=[::1]:9229

Example fix

# before
./dcore --inspect=localhost:9229 main.js  # invalid value 'localhost:9229'

# after
./dcore --inspect=127.0.0.1:9229 main.js
Defensive patterns

Strategy: validation

Validate before calling

// Validate before spawning dcore
function parseSocketAddr(v: string): { host: string; port: number } | null {
  const m = /^(\[([0-9a-fA-F:]+)\]|(\d+\.\d+\.\d+\.\d+)):(\d+)$/.exec(v);
  if (!m) return null; // rejects 'localhost:9229', '9229', ':9229'
  const port = Number(m[4]);
  return port > 0 && port < 65536 ? { host: m[2] ?? m[3], port } : null;
}
const flag = parseSocketAddr(inspectValue)
  ? `--inspect=${inspectValue}`
  : "--inspect"; // safe default

Type guard

// Rust (embedding dcore's arg parser)
fn is_valid_inspect_addr(v: &str) -> bool {
    v.parse::<std::net::SocketAddr>().is_ok()
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/fd3db2a14b64d5c2. Report an issue: GitHub.

Appendix: source

Thrown at libs/dcore/src/main.rs:180

  strace_ops_summary: bool,
  v8_flags: Vec<String>,
}

impl Args {
  /// Returns `Ok(None)` when `--help` was requested (usage already printed).
  fn parse(
    args: impl IntoIterator<Item = String>,
  ) -> Result<Option<Self>, Error> {
    let mut out = Args::default();
    let mut file_path: Option<String> = None;
    let mut seen_inspect_flag: Option<&'static str> = None;

    // `--inspect*` takes its value only via `=` (clap's `require_equals`), so
    // `--inspect 1.2.3.4:9229` treats the address as the positional argument.
    let parse_addr = |flag: &str, value: Option<&str>| match value {
      None => Ok(None),
      Some(v) => v.parse::<SocketAddr>().map(Some).map_err(|e| {
        anyhow::anyhow!("invalid value '{v}' for '{flag}=<HOST_AND_PORT>': {e}")
      }),
    };

    for arg in args {
      let (name, value) = match arg.split_once('=') {
        Some((name, value)) => (name, Some(value)),
        None => (arg.as_str(), None),
      };
      match name {
        "-h" | "--help" => {
          println!("{USAGE}");
          return Ok(None);
        }
        "--inspect" | "--inspect-brk" | "--inspect-wait" => {
          if let Some(previous) = seen_inspect_flag {
            bail!("the argument '{previous}' cannot be used with '{name}'");
          }
          seen_inspect_flag = Some(match name {

View on GitHub (pinned to 9ad36f7a2c)