affaan-m/ECC · error · anyhow::Error
Cannot rebase active session {} while it is {}
Error message
Cannot rebase active session {} while it is {} What it means
The rebase_session_worktree function refuses to rebase a session whose state is still active (Pending, Running, Idle, or Stale). Rebasing rewrites the worktree branch history, which would corrupt any in-flight agent work. The session must reach a terminal state before rebasing is safe.
Source
Thrown at ecc2/src/session/manager.rs:1817
}
Ok(WorktreeMergeOutcome {
session_id: session.id,
branch: outcome.branch,
base_branch: outcome.base_branch,
already_up_to_date: outcome.already_up_to_date,
cleaned_worktree: cleanup_worktree,
})
}
pub async fn rebase_session_worktree(db: &StateStore, id: &str) -> Result<WorktreeRebaseOutcome> {
let session = resolve_session(db, id)?;
if matches!(
session.state,
SessionState::Pending | SessionState::Running | SessionState::Idle | SessionState::Stale
) {
anyhow::bail!(
"Cannot rebase active session {} while it is {}",
session.id,
session.state
);
}
let worktree = session
.worktree
.clone()
.ok_or_else(|| anyhow::anyhow!("Session {} has no attached worktree", session.id))?;
let outcome = crate::worktree::rebase_onto_base(&worktree)?;
Ok(WorktreeRebaseOutcome {
session_id: session.id,
branch: outcome.branch,
base_branch: outcome.base_branch,
already_up_to_date: outcome.already_up_to_date,
})View on GitHub (pinned to 01e15490f0)
Solutions
- Stop or complete the session before calling rebase_session_worktree
- Check session state is terminal before attempting rebase
- For stale sessions, resolve them to a terminal state first (fail or cancel)
- Schedule rebases for after session completion rather than during
Example fix
// before
rebase_session_worktree(db, &id).await?;
// after
let session = resolve_session(db, &id)?;
if matches!(session.state, SessionState::Pending | SessionState::Running | SessionState::Idle | SessionState::Stale) {
return Err(anyhow!("Stop session {} before rebasing (current state: {})", id, session.state));
}
rebase_session_worktree(db, &id).await?; Defensive patterns
Strategy: type-guard
Validate before calling
let session = resolve_session(db, id)?;
if matches!(session.state, SessionState::Pending | SessionState::Running | SessionState::Idle | SessionState::Stale) {
return Err(anyhow!("Stop session {} (state: {}) before rebasing", id, session.state));
} Type guard
fn is_rebaseable(session: &Session) -> bool {
!matches!(
session.state,
SessionState::Pending | SessionState::Running | SessionState::Idle | SessionState::Stale
)
} Prevention
- Only expose rebase actions for terminal-state sessions
- Call stop_session before rebase in automated workflows
- Schedule rebases as a post-completion step rather than during session execution
When it happens
Trigger: Calling rebase_session_worktree(db, id) for a session in SessionState::Pending, Running, Idle, or Stale.
Common situations: User triggers a rebase to pull in latest base-branch changes while the session is still running. Stale sessions are still blocked because the agent process may still be alive.
Related errors
- Cannot merge active session {} while it is {}
- Completed sessions cannot be resumed: {}
- Session is already running: {}
- Cannot delete active session {} while it is {}
- Session {} has no attached worktree
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/3dc226630172af1a.
Report an issue: GitHub.