{"record":{"id":"fe916ba52e97d523","repo":"Hmbown/CodeWhale","slug":"resume-session-id-needs-a-session-id-but-got-an-empty-value","errorCode":null,"errorMessage":"--resume/--session-id needs a session id, but got an empty value (an unset shell variable?). Use `codewhale --continue` to resume the most recent session.","messagePattern":"--resume/--session-id needs a session id, but got an empty value \\(an unset shell variable\\?\\)\\. Use `codewhale --continue` to resume the most recent session\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/lib.rs","lineNumber":2339,"sourceCode":"    }\n}\n\nfn root_tui_passthrough(cli: &Cli) -> Result<Vec<String>> {\n    let mut forwarded = Vec::new();\n    if cli.continue_session {\n        forwarded.push(\"--continue\".to_string());\n    }\n    let resume_session_id = cli\n        .resume\n        .as_deref()\n        .or(cli.session_id.as_deref())\n        .map(str::trim);\n    if resume_session_id.is_some_and(str::is_empty) {\n        // A shell expanding an unset variable -- `codewhale --resume\n        // \"$SESSION_ID\"` -- must not quietly become a fresh session. The user\n        // asked to resume; starting new loses the session they meant, and the\n        // mistake is invisible until the history is gone.\n        bail!(\n            \"--resume/--session-id needs a session id, but got an empty value \\\n             (an unset shell variable?). Use `codewhale --continue` to resume \\\n             the most recent session.\"\n        );\n    }\n    if let Some(session_id) = resume_session_id {\n        forwarded.push(\"--resume\".to_string());\n        forwarded.push(session_id.to_string());\n    }\n\n    let prompt =\n        cli.prompt_flag\n            .iter()\n            .chain(cli.prompt.iter())\n            .fold(String::new(), |mut acc, part| {\n                if !acc.is_empty() {\n                    acc.push(' ');\n                }","sourceCodeStart":2321,"sourceCodeEnd":2357,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/cli/src/lib.rs#L2321-L2357","documentation":"The resume path trims the supplied `--resume`/`--session-id` value and bails if it is empty. The guard exists because a shell expanding an unset variable (`codewhale --resume \"$SESSION_ID\"`) would otherwise quietly start a fresh session, and the loss of intended history is invisible until it is too late. The error suggests `--continue` to resume the most recent session.","triggerScenarios":"Passing `--resume \"\"`, `--session-id \" \"`, or `--resume \"$SESSION_ID\"` / `--session-id \"$ID\"` where the shell variable is unset or empty.","commonSituations":"CI scripts or shell aliases with unset environment variables, sourcing order mistakes where SESSION_ID is defined in a different shell, or users forgetting to paste the id.","solutions":["Provide the actual session id: `codewhale --resume <real-session-id>`.","If you just want the latest session, use `codewhale --continue` instead.","Guard shell scripts: `: \"${SESSION_ID:?SESSION_ID is not set}\"` before invoking.","List available sessions (`codewhale sessions` or the session store) to find the correct id."],"exampleFix":"// before\ncodewhale --resume \"$SESSION_ID\"   # unset\n// error: --resume/--session-id needs a session id, but got an empty value...\n\n// after\ncodewhale --resume 3f9c1a2e-... \n// or: codewhale --continue","handlingStrategy":"fallback","validationCode":"# shell guard\nif [ -z \"${SESSION_ID:-}\" ]; then\n  echo \"SESSION_ID empty; falling back to --continue\" >&2\n  exec codewhale --continue\nfi\ncodewhale --resume \"$SESSION_ID\"","typeGuard":null,"tryCatchPattern":"match run(args) {\n    Err(e) if e.to_string().contains(\"got an empty value\") => {\n        eprintln!(\"empty session id; use `codewhale --continue` for the latest session\");\n    }\n    r => r?,\n}","preventionTips":["Guard interpolated ids with ${VAR:?msg} in scripts.","Use --continue when you do not have a concrete id.","Capture the session id from the command that created the session, not from memory."],"tags":["cli","session","shell","validation"],"backgroundTag":"empty-required-field","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T21:17:16.096Z"}