{"record":{"id":"69a3cab83c910e8c","repo":"nikivdev/code","slug":"failed-to-continue-session-for","errorCode":null,"errorMessage":"failed to continue {} session {} for {}","messagePattern":"failed to continue (.+?) session (.+?) for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai.rs","lineNumber":5481,"sourceCode":"                target.display()\n            )\n        })?;\n        println!(\n            \"Resuming session {} from {}...\",\n            &sess.session_id[..8.min(sess.session_id.len())],\n            target.display()\n        );\n        if launch_session_for_target(\n            &sess.session_id,\n            sess.provider,\n            None,\n            Some(&target),\n            None,\n            None,\n        )? {\n            return Ok(());\n        }\n        bail!(\n            \"failed to continue {} session {} for {}\",\n            provider_name(sess.provider),\n            sess.session_id,\n            target.display()\n        );\n    }\n\n    let launched = match provider {\n        Provider::Claude => launch_claude_continue()?,\n        Provider::Codex => launch_codex_continue_last_for_target(None, false)?,\n        Provider::Cursor => false,\n        Provider::All => false,\n    };\n\n    if launched {\n        Ok(())\n    } else {\n        bail!(\"failed to continue {} session\", provider_name(provider))","sourceCodeStart":5463,"sourceCodeEnd":5499,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai.rs#L5463-L5499","documentation":"When a specific session's resume command is dispatched but the provider CLI exits without successfully continuing that session, src/ai.rs:5481 bails with the provider name, session id, and target path in the message. This indicates the launch attempt for that exact session record failed, not a missing session file.","triggerScenarios":"resume_session for an existing session record (sess.provider, sess.session_id, target) whose launch path returns without success — provider CLI exited non-zero, session id no longer valid on disk, or the provider binary refused the flags used to continue it.","commonSituations":"Session file exists in the target dir but the provider CLI deleted/expired that session id (version upgrade changing session storage); provider CLI not authenticated so it exits immediately; corrupted session transcript rejected by the CLI.","solutions":["Re-run the continue command to surface the provider CLI's own error output","Verify the session id still exists in the provider's native session store (~/.claude/projects, ~/.codex/sessions)","Re-authenticate the provider CLI (claude login / codex auth) and retry","Delete or ignore the stale session and start a new one (`f ai <provider> continue` without id creates new)"],"exampleFix":"// before: stale session id from an old provider version\n$ f ai codex continue --session abc123-old-format\n// after: let it resume the latest or start fresh\n$ f ai codex continue","handlingStrategy":"fallback","validationCode":"if !provider_session_exists(target, &session_id) {\n    eprintln!(\"Session {} not found for {}; starting a new one instead.\", session_id, target.display());\n    return continue_session(provider, None, Some(target));\n}","typeGuard":"fn is_resume_failure(msg: &str) -> bool {\n    msg.starts_with(\"failed to continue\")\n}","tryCatchPattern":"match resume_session(session, path, provider) {\n    Err(e) if e.to_string().starts_with(\"failed to continue\") => {\n        eprintln!(\"{e} — falling back to launching a new session\");\n        let _ = continue_session(provider, None, path);\n    }\n    other => other?,\n}","preventionTips":["Re-authenticate the provider CLI so launches don't exit early","Drop stale session ids after provider upgrades (session storage formats change)","Verify the session id exists in the provider's native store before resuming","Keep the project target path stable — session records are keyed to it"],"tags":["cli","session-resume","provider-cli"],"backgroundTag":"session-resume-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}