jdx/mise · error
firewall rule ' ' sets port without protocol
Error message
firewall rule '{name}' sets port without protocol What it means
A rule sets a `port` but omits `protocol`. A port number is only meaningful for a transport protocol (tcp/udp); without `protocol` mise cannot emit a valid nftables/ufw/firewalld rule, so from_toml rejects the combination at parse time.
Solutions
- Add `protocol = "tcp"` (or "udp") to the rule alongside the port.
- If you want to allow all ports, remove the `port` field and rely on protocol/state/action alone.
- Define two rules with distinct ports/protocols if both tcp and udp are needed.
Example fix
// before [[firewall.rules]] name = "allow-ssh" port = 22 action = "allow" // after [[firewall.rules]] name = "allow-ssh" port = 22 protocol = "tcp" action = "allow"
Defensive patterns
Strategy: validation
Validate before calling
for rule in &firewall_config.rules {
if rule.port.is_some() && rule.protocol.is_none() {
return Err(format!("rule '{}' sets port without protocol", rule.name));
}
} Type guard
fn port_rule_has_protocol(rule: &FirewallRuleToml) -> bool {
rule.port.is_none() || rule.protocol.is_some()
} Try / catch
match FirewallRequest::from_toml(cfg) {
Err(e) if e.to_string().contains("port without protocol") => {
eprintln!("add protocol = \"tcp\" or \"udp\" to the rule");
}
other => other?,
} Prevention
- Always write port and protocol on adjacent lines so one cannot be omitted.
- Template rules with a default protocol = "tcp" fill-in.
- Validate config with `mise bootstrap firewall status` (dry inspection) before applying.
When it happens
Trigger: Writing `[[firewall.rules]]` with `port = 22` but no `protocol = "tcp"` and running a firewall bootstrap command (`mise bootstrap firewall ...`) that constructs FirewallRequest::from_toml. Fires whenever port.is_some() && protocol.is_none().
Common situations: Copying a rule snippet that used a default protocol implicitly; hand-writing config assuming tcp is the default; tooling that fills port but not protocol.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- brew-cask: : unsupported base
- brew-cask: : unsupported run guard condition
- brew-cask: : unsupported run guard platform
- firewall rule ' ' is declared more than once
- firewall rule ' ' mixes IPv4 and IPv6 source/destination…
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/6b6e6c28a9691f5d.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/firewall.rs:426
.source
.map(|source| source.parse::<IpNet>())
.transpose()
.wrap_err_with(|| format!("firewall rule '{name}' has an invalid source"))?;
let destination = rule
.destination
.map(|destination| destination.parse::<IpNet>())
.transpose()
.wrap_err_with(|| format!("firewall rule '{name}' has an invalid destination"))?;
if source.is_some_and(|source| {
destination.is_some_and(|destination| {
source.addr().is_ipv4() != destination.addr().is_ipv4()
})
}) {
bail!("firewall rule '{name}' mixes IPv4 and IPv6 source/destination networks");
}
let port = rule.port.map(FirewallPort::from_toml).transpose()?;
if port.is_some() && rule.protocol.is_none() {
bail!("firewall rule '{name}' sets port without protocol");
}
rules.push(FirewallRule {
name,
state: rule.state,
direction: rule.direction,
action: rule.action,
port,
protocol: rule.protocol,
source,
destination,
interface,
});
}
let ssh_connection = std::env::var("SSH_CONNECTION")
.ok()
.map(|value| parse_ssh_connection(&value))
.transpose()?;
let request = Self {View on GitHub (pinned to 533346cc37)