astrid-runtime/astrid · error

commands::daemon::unreachable_uplink_message()

Error message

commands::daemon::unreachable_uplink_message()

What it means

run_or_connect matches on the EnsureAction returned when ensuring a daemon is up. RefuseSecondBoot is an action that the current daemon bootstrap logic is not supposed to produce on this code path; hitting it indicates the daemon command layer returned an action that run_or_connect cannot meaningfully handle. The error uses a shared helper, commands::daemon::unreachable_uplink_message(), signaling an internal invariant violation ("this branch should be unreachable").

Source

Thrown at crates/astrid-cli/src/bootstrap.rs:205

        .await
        .context("Failed to check socket")?;
    let action = commands::daemon::decide_ensure_action(
        &outcome,
        commands::daemon::recorded_daemon_pid_is_alive(),
    );
    let needs_boot = match action {
        commands::daemon::EnsureAction::UseExisting => {
            if let astrid_core::local_transport::ConnectOutcome::Connected(stream) = outcome {
                drop(stream);
            }
            println!(
                "{}",
                theme::Theme::info("Connecting to existing Astrid daemon...")
            );
            false
        },
        commands::daemon::EnsureAction::RefuseSecondBoot => {
            anyhow::bail!(commands::daemon::unreachable_uplink_message());
        },
        commands::daemon::EnsureAction::CleanStaleAndSpawn => {
            println!(
                "{}",
                theme::Theme::warning("Found dead socket. Cleaning up and restarting daemon...")
            );
            astrid_core::local_transport::remove_stale_endpoint(&socket_path)
                .context("failed to clean up stale daemon endpoint")?;
            let _ = std::fs::remove_file(&ready_path);
            true
        },
        commands::daemon::EnsureAction::Spawn => true,
    };

    let mut daemon_child: Option<std::process::Child> = None;

    if needs_boot {
        match commands::daemon::spawn_daemon(&ready_path, workspace_root.as_deref()).await {

View on GitHub (pinned to affd8760f4)

Solutions

  1. Check CLI/daemon versions match; upgrade both from the same release.
  2. Inspect daemon socket/state files for a stale or corrupted boot record causing the refuse classification, and clean the daemon state.
  3. Report this as a bug with the reproduction — the branch is explicitly unreachable by design.
  4. As a workaround, restart cleanly: remove the stale socket and re-run the command.

Example fix

// before: ensure() can return RefuseSecondBoot to run_or_connect
let action = ensure_daemon(...)?;

// after (fix): keep refuse-second-boot decisions inside spawn paths only
match ensure_daemon(...)? {
    EnsureAction::ConnectExisting | EnsureAction::CleanStaleAndSpawn => { /* as today */ }
    EnsureAction::RefuseSecondBoot => unreachable!("handled inside ensure_daemon"),
}
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure CLI and daemon versions match before booting
let cli = env!("CARGO_PKG_VERSION");
if daemon_reported_version()? != cli {
    eprintln!("version skew between CLI and daemon; upgrade both");
}

Type guard

fn is_handleable(action: &EnsureAction) -> bool {
    !matches!(action, EnsureAction::RefuseSecondBoot)
}

Try / catch

match run_or_connect(&config).await {
    Ok(()) => { /* ... */ }
    Err(e) if e.to_string().contains("unreachable_uplink_message") ||
              e.to_string().contains("RefuseSecondBoot") => {
        eprintln!("internal daemon-state bug; clean socket state and report");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling run_or_connect and receiving EnsureAction::RefuseSecondBoot from the daemon ensure routine — i.e. the ensure logic decided to refuse a second boot in a context where that decision should never be made (e.g. mismatch between the ensure-mode requested and the one implemented).

Common situations: Version skew between the CLI and daemon components where one emits an action the other doesn't expect; a bug in daemon state classification (mis-detecting an existing boot); manually crafted ensure configurations triggering the refuse path.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/049f2710eb224b4f. Report an issue: GitHub.