jdx/mise · error

firewall port range - is invalid

Error message

firewall port range {start}-{end} is invalid

What it means

After splitting a firewall port range into endpoints and parsing both as `u16`, `FirewallPort::from_toml` validates that neither bound is 0 and that start <= end. Violating any of these yields this error with the parsed (possibly mis-ordered) bounds, since a zero port is invalid and an inverted range matches nothing.

Solutions

  1. Order the endpoints ascending, e.g. `"8000-9000"`
  2. Use port numbers 1-65535; replace 0 with a real port
  3. For a single port, write it as a number rather than a range

Example fix

// before (mise.toml)
[[firewall.rules]]
ports = ["9000-8000"]

// after
[[firewall.rules]]
ports = ["8000-9000"]
Defensive patterns

Strategy: validation

Validate before calling

function validRange(a, b) {
  return a >= 1 && b >= 1 && a <= 65535 && b <= 65535 && a <= b;
}

Prevention

When it happens

Trigger: Config values like `"9000-8000"` (inverted), `"0-80"` or `"80-0"` (zero bound), or values > 65535 that fail `u16::parse` earlier but whose parse errors surface similarly from this function.

Common situations: Hand-written firewall rules with swapped endpoints, off-by-one/zero typos, or copying Linux iptables-style `0` semantics that this parser rejects.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/67c15c9bbc0cb267. Report an issue: GitHub.

Appendix: source

Thrown at src/system/firewall.rs:205

#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub(crate) struct FirewallPort {
    start: u16,
    end: u16,
}

impl FirewallPort {
    fn from_toml(value: FirewallPortToml) -> Result<Self> {
        let (start, end) = match value {
            FirewallPortToml::Single(port) => (port, port),
            FirewallPortToml::Range(range) => {
                let Some((start, end)) = range.split_once(['-', ':']) else {
                    bail!("firewall port '{range}' must be a number or inclusive range")
                };
                (start.parse()?, end.parse()?)
            }
        };
        if start == 0 || end == 0 || start > end {
            bail!("firewall port range {start}-{end} is invalid");
        }
        Ok(Self { start, end })
    }

    fn contains(self, port: u16) -> bool {
        self.start <= port && port <= self.end
    }

    fn render(self, separator: char) -> String {
        if self.start == self.end {
            self.start.to_string()
        } else {
            format!("{}{separator}{}", self.start, self.end)
        }
    }
}

#[derive(Clone, Debug, Deserialize)]

View on GitHub (pinned to 533346cc37)