Hmbown/CodeWhale · error

lane ` ` runtime ` ` has no attach target

Error message

lane `{lane_id}` runtime `{}` has no attach target

What it means

The sibling case of the attach resolution: the lane's status IS active, but the backend still could not produce an attach command, so the failure names the lane's runtime instead — 'lane `<id>` runtime `<runtime>` has no attach target'. This means the lane claims to be running but its runtime backend cannot expose an attachable session (e.g. the underlying tmux session or process handle is gone).

Solutions

  1. Reconcile the lane (`backend.reconcile` runs on attach already, but run `codewhale lane --status`) to refresh state, then retry attach.
  2. If the runtime session is truly gone, restart the lane and attach to the new one.
  3. Check the lane's `runtime` value — if the runtime type doesn't support attach, use the appropriate runtime (tmux) for interactive attach.

Example fix

// before: lane marked active but tmux session gone
codewhale lane attach lane-7
// after
codewhale lane control restart lane-7
codewhale lane attach lane-7
Defensive patterns

Strategy: retry

Validate before calling

const lane = await showLane(id);
if (lane.status === 'active') verifyRuntimeSession(lane.runtime); // e.g. `tmux -S <socket> has -t <session>`

Try / catch

for (let i = 0; i < 2; i++) {
  try { return attach(id); }
  catch (e) { if (!/no attach target/.test(e.message)) throw e; restartLane(id); }
}

Prevention

When it happens

Trigger: Attaching to an active-status lane whose `backend.attach_command` returns None — typically the runtime's session vanished (tmux server died, session killed externally) while lane state still says active, or a runtime kind that does not support attach.

Common situations: tmux session killed outside codewhale; machine reboot leaving stale lane state marked active; attaching to a lane using a runtime that lacks attach support.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/3801e1430d4c12c4. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/lib.rs:955

        LaneCommand::Restart { lane_id, json } => {
            run_lane_control(ControlOperation::LaneRestart, Some(&lane_id), json)
        }
        LaneCommand::Resume { lane_id, json } => {
            run_lane_control(ControlOperation::LaneResume, Some(&lane_id), json)
        }
        LaneCommand::Attach { lane_id, print } => {
            let reg = LaneRegistry::open_default()?;
            let mut lane = reg.load(&lane_id)?;
            let backend = backend_for(&lane);
            backend.reconcile(&reg, &mut lane)?;
            let Some(attach) = backend.attach_command(&lane) else {
                if !lane.status.is_active() {
                    bail!(
                        "lane `{lane_id}` is {} and has no active attach target",
                        lane.status.as_str()
                    );
                }
                bail!(
                    "lane `{lane_id}` runtime `{}` has no attach target",
                    lane.runtime.as_str()
                );
            };
            if print {
                println!("{attach}");
                return Ok(());
            }
            if let Some(session) = lane.tmux_session.as_deref() {
                let socket = lane
                    .tmux_socket
                    .as_deref()
                    .context("tmux lane is missing its pinned server socket")?;
                let status = Command::new("tmux")
                    .arg("-S")
                    .arg(socket)
                    .args(["attach", "-t", session])
                    .status();

View on GitHub (pinned to 73e0f67d83)