{"record":{"id":"fd204adf13b73a54","repo":"Hmbown/CodeWhale","slug":"job-task-id-not-found","errorCode":null,"errorMessage":"Job {task_id} not found","messagePattern":"Job (.+?) not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/shell.rs","lineNumber":1852,"sourceCode":"                \"foreground_background_requested\",\n                &self.foreground_background_requested,\n            )\n            .finish()\n    }\n}\n\nimpl ShellManager {\n    fn require_session_owner(&self, task_id: &str, active_session_id: &str) -> Result<()> {\n        let owned = self.processes.get(task_id).is_some_and(|shell| {\n            !active_session_id.is_empty() && shell.owner_session_id == active_session_id\n        }) || self.stale_jobs.get(task_id).is_some_and(|job| {\n            !active_session_id.is_empty() && job.owner_session_id == active_session_id\n        });\n        if owned {\n            Ok(())\n        } else {\n            // Do not disclose whether the id exists in another session.\n            Err(anyhow!(\"Job {task_id} not found\"))\n        }\n    }\n\n    /// Create a new `ShellManager` with default (no sandbox) policy.\n    pub fn new(workspace: PathBuf) -> Self {\n        Self {\n            processes: HashMap::new(),\n            stale_jobs: HashMap::new(),\n            default_workspace: workspace,\n            sandbox_manager: SandboxManager::new(),\n            sandbox_policy: ExecutionSandboxPolicy::default(),\n            foreground_background_requested: false,\n            output_spill_dir: None,\n        }\n    }\n\n    /// Point lowercase-`bash` complete-output spill files at `dir` instead of\n    /// the process temp dir. Tests use a nonexistent dir to simulate a full or","sourceCodeStart":1834,"sourceCodeEnd":1870,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/shell.rs#L1834-L1870","documentation":"ShellManager's ownership check deliberately returns a single \"Job {task_id} not found\" error when the caller's active session does not own the job — including the case where the job exists but belongs to a different session. The comment in source makes the intent explicit: do not disclose whether the id exists in another session, so both missing and foreign jobs map to the same message.","triggerScenarios":"Calling a shell job operation (kill, read, wait, etc.) with a task_id that either does not exist at all, was already reaped, or exists but is owned by a different session than the active_session_id being checked.","commonSituations":"A background shell job finished and was removed before the follow-up call; using a job id from another TUI/session or a stale session id after reconnecting; copy-pasting a job id from logs of a different workspace.","solutions":["List the jobs visible to your current session (via the shell tool's job listing) and use one of those ids.","Check whether the job already completed and was reaped — fetch its final output before it is removed.","Switch to (or re-check) the session that launched the job; job ids are session-scoped."],"exampleFix":"// before\nmanager.kill(\"shell_abc123\")?; // id from another session\n\n// after\nlet jobs = manager.list_jobs(&active_session_id);\nlet job = jobs.iter().find(|j| j.id == \"shell_abc123\")\n    .ok_or_else(|| anyhow!(\"no job shell_abc123 in this session\"))?;\nmanager.kill(&job.id)?;","handlingStrategy":"validation","validationCode":"// verify the id is visible in the current session before operating on it\nlet owned = manager.list_jobs(&active_session_id)\n    .iter().any(|j| j.id == task_id);\nif !owned { return Err(anyhow!(\"job {task_id} not found in this session\")); }","typeGuard":null,"tryCatchPattern":"// Rust: treat not-found as non-retryable; refresh the job list\nmatch manager.kill(task_id) {\n    Ok(()) => {}\n    Err(e) if e.to_string().ends_with(\"not found\") => {\n        // re-list jobs; the job either completed or belongs to another session\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always scope job ids to the session that created them.","Fetch job output before it is reaped/removed.","Handle 'not found' on follow-up calls as a normal completed-job outcome."],"tags":["shell","job","not-found","session-isolation"],"backgroundTag":"entity-not-found","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}