{"record":{"id":"0b9ce7e1c42250bb","repo":"jdx/mise","slug":"firewall-rule-name-is-declared-more-than-once","errorCode":null,"errorMessage":"firewall rule '{name}' is declared more than once","messagePattern":"firewall rule '(.+?)' is declared more than once","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/firewall.rs","lineNumber":401,"sourceCode":"            \"--no-hooks\".to_string(),\n            \"bootstrap\".to_string(),\n            \"__inspect-firewall-plan\".to_string(),\n        ],\n        &input,\n    )?;\n    request.inspection = Some(serde_json::from_slice(&output)?);\n    Ok(())\n}\n\nimpl FirewallRequest {\n    fn from_toml(config: FirewallTomlConfig) -> Result<Self> {\n        let mut rules = vec![];\n        let mut names = HashSet::new();\n        for rule in config.rules {\n            let name = rule.name;\n            validate_name(&name)?;\n            if !names.insert(name.clone()) {\n                bail!(\"firewall rule '{name}' is declared more than once\");\n            }\n            let interface = rule\n                .interface\n                .map(|interface| validate_interface(interface.trim()))\n                .transpose()?;\n            let source = rule\n                .source\n                .map(|source| source.parse::<IpNet>())\n                .transpose()\n                .wrap_err_with(|| format!(\"firewall rule '{name}' has an invalid source\"))?;\n            let destination = rule\n                .destination\n                .map(|destination| destination.parse::<IpNet>())\n                .transpose()\n                .wrap_err_with(|| format!(\"firewall rule '{name}' has an invalid destination\"))?;\n            if source.is_some_and(|source| {\n                destination.is_some_and(|destination| {\n                    source.addr().is_ipv4() != destination.addr().is_ipv4()","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/firewall.rs#L383-L419","documentation":"mise's firewall bootstrap configuration parses `[firewall]` TOML rules into a FirewallRequest, and rule names are used as stable identifiers for idempotent application and plan previews. Two rules sharing the same name would make ordering, dedup, and lockout analysis ambiguous, so from_toml rejects the second occurrence via a HashSet uniqueness check at parse time.","triggerScenarios":"Calling the firewall bootstrap path (e.g. `mise bootstrap firewall ...` or the internal __inspect-firewall-plan pipeline) with a mise.toml that defines two firewall rules whose `name` fields are identical. The check runs in FirewallRequest::from_toml right after validate_name.","commonSituations":"Copy-pasting a rule block to tweak one field (port, direction) but forgetting to rename it; merging config files from two machines that each defined the same rule name; generating config in a script that emits duplicate names.","solutions":["Find the duplicate `[[firewall.rules]]` entry with that name in your mise.toml and give one of them a unique name.","If the rules are meant to be identical, delete the redundant one.","If the rules intentionally differ, rename each to describe its purpose (e.g. 'allow-ssh-wan', 'allow-http-lan')."],"exampleFix":"// before (mise.toml)\n[[firewall.rules]]\nname = \"allow-http\"\nport = 80\nprotocol = \"tcp\"\naction = \"allow\"\n\n[[firewall.rules]]\nname = \"allow-http\"\nport = 443\nprotocol = \"tcp\"\naction = \"allow\"\n\n// after\n[[firewall.rules]]\nname = \"allow-http\"\nport = 80\nprotocol = \"tcp\"\naction = \"allow\"\n\n[[firewall.rules]]\nname = \"allow-https\"\nport = 443\nprotocol = \"tcp\"\naction = \"allow\"","handlingStrategy":"validation","validationCode":"let names: Vec<&str> = firewall_config.rules.iter().map(|r| r.name.as_str()).collect();\nlet dupes: Vec<&str> = names.iter().filter(|n| names.iter().filter(|m| m == n).count() > 1).map(|n| *n).collect();\nif !dupes.is_empty() { return Err(format!(\"duplicate firewall rule names: {dupes:?}\")); }","typeGuard":"fn has_unique_rule_names(rules: &[FirewallRuleToml]) -> bool {\n    let mut seen = std::collections::HashSet::new();\n    rules.iter().all(|r| seen.insert(&r.name))\n}","tryCatchPattern":"match FirewallRequest::from_toml(cfg) {\n    Err(e) if e.to_string().contains(\"declared more than once\") => {\n        eprintln!(\"fix duplicate [[firewall.rules]] names in mise.toml\");\n    }\n    other => other?,\n}","preventionTips":["Keep one canonical rule list; generate rules programmatically with unique name suffixes.","Lint your mise.toml for duplicate keys in CI before deploying.","Name rules by purpose plus qualifier (e.g. allow-https-v4, allow-https-v6)."],"tags":["firewall","config-validation","duplicate-name"],"backgroundTag":"invalid-config-value","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}