{"record":{"id":"b43c1c7c64264163","repo":"xai-org/grok-build","slug":"session-name-not-found","errorCode":null,"errorMessage":"session '{name}' not found","messagePattern":"session '(.+?)' not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/ptyctl-cli/src/registry.rs","lineNumber":53,"sourceCode":"\n    let path = dir.join(format!(\"{name}.json\"));\n    let json = serde_json::to_string_pretty(info)?;\n\n    // Atomic write: write to temp file, then rename.\n    let tmp = dir.join(format!(\".{name}.json.tmp\"));\n    fs::write(&tmp, &json).context(\"failed to write session file\")?;\n    fs::rename(&tmp, &path).context(\"failed to rename session file\")?;\n\n    Ok(())\n}\n\n/// Look up a named session.\npub fn lookup_session(name: &str) -> Result<SessionInfo> {\n    let dir = registry_dir()?;\n    let path = dir.join(format!(\"{name}.json\"));\n\n    if !path.exists() {\n        bail!(\"session '{name}' not found\");\n    }\n\n    let json = fs::read_to_string(&path).context(\"failed to read session file\")?;\n    let info: SessionInfo = serde_json::from_str(&json).context(\"failed to parse session file\")?;\n\n    Ok(info)\n}\n\n/// Remove a named session.\npub fn unregister_session(name: &str) -> Result<()> {\n    let dir = registry_dir()?;\n    let path = dir.join(format!(\"{name}.json\"));\n    if path.exists() {\n        fs::remove_file(&path).context(\"failed to remove session file\")?;\n    }\n    Ok(())\n}\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/ptyctl-cli/src/registry.rs#L35-L71","documentation":"lookup_session() reads `<registry_dir>/<name>.json` to resolve a named session. If the file does not exist, the name is unknown and this error is returned.","triggerScenarios":"Any operation targeting a session by name (--name, stop, screen, keys, to_url with name) when no `<name>.json` exists in the registry directory — the session was never created with that name or the registry was cleared.","commonSituations":"Typo in session name; running commands from a different user/HOME so the registry dir differs; registry cleaned between test runs; session never started.","solutions":["List existing sessions (`ptyctl list` or ls the registry dir) and use a valid name","Start the session first: `ptyctl run --name <n> ...`","Check for typos in the name","Confirm you run as the same user (registry dir is per-user/HOME-dependent)"],"exampleFix":"// before\nptyctl screen --name devsession\n// after (after listing available names)\nptyctl screen --name dev-session","handlingStrategy":"validation","validationCode":"fn ensure_session_known(name: &str) -> anyhow::Result<()> {\n    let dir = registry_dir()?;\n    if !dir.join(format!(\"{name}.json\")).exists() {\n        anyhow::bail!(\"session '{name}' not registered; run 'ptyctl list' or start it first\");\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match registry::lookup_session(name) {\n    Ok(info) => use_session(info),\n    Err(e) if e.to_string().contains(\"not found\") => {\n        eprintln!(\"unknown session; pick a valid name from 'ptyctl list'\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["List sessions before name-based commands","Double-check spelling of --name values","Run as the same user that created the session (per-user registry dir)","Start sessions in setup steps before dependent commands"],"tags":["cli","registry","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}