jdx/mise · error

refusing unsafe firewall change; inspect `mise bootstrap…

Error message

refusing unsafe firewall change; inspect `mise bootstrap firewall status`

What it means

The firewall apply step computes a plan and validates it against safety invariants (no lockout, no manual-intervention resources). If a resource is in a state mise cannot safely change automatically (e.g. drift it would have to force) or the plan is otherwise unsafe, apply bails out with this generic refusal instead of mutating the firewall. The error directs you to the read-only inspection command for details.

Solutions

  1. Run `mise bootstrap firewall status` to see the current vs desired state and which resource is unsafe.
  2. Reconcile the drifted resource manually (delete/fix the conflicting rule) so the plan becomes safe.
  3. Re-run apply after the manual fix; verify with a dry run first.
  4. If allow_lockout gating was the cause, add a covering SSH allow rule or set allow_lockout = true, then retry.

Example fix

// before
$ mise bootstrap firewall apply
error: refusing unsafe firewall change...

// after
$ mise bootstrap firewall status   # inspect current vs desired
$ # fix conflicting rule manually, then:
$ mise bootstrap firewall apply
Defensive patterns

Strategy: try-catch

Validate before calling

// inspect first, apply second
let status = cmd("mise").args(["bootstrap", "firewall", "status"]).output()?;
println!("{}", String::from_utf8_lossy(&status.stdout)); // confirm plan is clean before apply

Try / catch

match result {
    Err(e) if e.to_string().contains("refusing unsafe firewall change") => {
        let status = cmd("mise").args(["bootstrap", "firewall", "status"]).output()?;
        eprintln!("unsafe plan; inspect:\n{}", String::from_utf8_lossy(&status.stdout));
    }
    other => other?,
}

Prevention

When it happens

Trigger: Running `mise bootstrap firewall apply` when the plan contains resources whose current state differs from desired in a way flagged manual-action-required, or when a safety check upstream failed and apply reached the terminal bail in FirewallRequest::apply.

Common situations: Hand-edited nftables/ufw state diverging from what mise manages; rules created by another tool (Docker, firewalld zones) conflicting with the plan; partial previous apply that left drifted resources; concurrent firewall changes from another admin.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at src/system/firewall.rs:726

        .count();
    if changes == 0 {
        info!("firewall: already converged");
        return Ok(());
    }
    if firewall_change_is_unsafe(&plan) {
        if dry_run {
            for resource in plan
                .iter()
                .filter(|resource| resource.action == ResourceAction::Unknown)
            {
                warn!(
                    "would not change {}: current {}, desired {} (manual action required)",
                    resource.id, resource.current, resource.desired
                );
            }
            return Ok(());
        }
        bail!("refusing unsafe firewall change; inspect `mise bootstrap firewall status`");
    }
    if dry_run {
        let inspection = request.inspection.as_ref().expect("firewall was inspected");
        let backend = inspection.backend.expect("available firewall backend");
        for command in preview_commands(request, backend)? {
            miseprintln!("would run {}", shell_words::join(command));
        }
        return Ok(());
    }
    let destructive = request.exclusive
        || matches!(
            request.state,
            FirewallState::Disabled | FirewallState::Absent
        )
        || plan
            .iter()
            .any(|resource| resource.action == ResourceAction::Remove);
    if !yes

View on GitHub (pinned to 533346cc37)