{"record":{"id":"f6024aea22f27fea","repo":"xai-org/grok-build","slug":"session-directory-is-unknown-cannot-probe-disk-sp","errorCode":null,"errorMessage":"session directory is unknown; cannot probe disk space","messagePattern":"session directory is unknown; cannot probe disk space","errorType":"error_code","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shell/src/session/persistence.rs","lineNumber":1603,"sourceCode":"                message: DISK_FULL_USER_MESSAGE.to_string(),\n            }),\n            meta: None,\n        };\n        if let Ok(params) = serde_json::value::to_raw_value(&notification) {\n            gateway.forward_fire_and_forget(acp::ExtNotification::new(\n                \"x.ai/session_notification\",\n                params.into(),\n            ));\n        }\n    }\n\n    async fn probe_writable(&self) -> io::Result<()> {\n        let dir = self\n            .storage\n            .updates_file_path(&self.info)\n            .and_then(|path| path.parent().map(Path::to_path_buf))\n            .ok_or_else(|| {\n                io::Error::new(\n                    io::ErrorKind::NotFound,\n                    \"session directory is unknown; cannot probe disk space\",\n                )\n            })?;\n        tokio::task::spawn_blocking(move || {\n            std::fs::create_dir_all(&dir)?;\n            let probe = dir.join(\".disk_ok\");\n            std::fs::write(&probe, b\"ok\")?;\n            let _ = std::fs::remove_file(&probe);\n            io::Result::Ok(())\n        })\n        .await\n        .map_err(io::Error::other)?\n    }\n\n    fn queue_acp_sync(&self, notification: acp::SessionNotification) {\n        if let Some(sync) = &self.remote_sync {\n            sync.queue(notification.clone());","sourceCodeStart":1585,"sourceCodeEnd":1621,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shell/src/session/persistence.rs#L1585-L1621","documentation":"The writability/disk-space probe (probe_writable) derives the session directory as the parent of the updates file path; when storage.updates_file_path(&self.info) returns None (or has no parent), the probe cannot determine where to check disk space and fails with io::ErrorKind::NotFound before any spawn_blocking work.","triggerScenarios":"Calling probe_writable on a persistence instance whose updates_file_path resolves to None — e.g. session info lacks a valid session id/path mapping, or storage backend is not filesystem-backed.","commonSituations":"Session opened with a synthetic/empty id before the directory was assigned; storage configured to a mode that doesn't produce a path; probing before session initialization completed.","solutions":["Ensure the session is fully initialized (valid id and storage path) before probing writability","Check the storage configuration so updates_file_path returns a real filesystem path","Initialize the session directory explicitly before starting persistence","Skip the probe or supply a default session directory when the path is unknown"],"exampleFix":"// before: probing immediately after constructing an uninitialized session\npersist.probe_writable().await?;\n// after: initialize first\nlet persist = SessionPersistence::init(info, storage).await?;\npersist.probe_writable().await?;","handlingStrategy":"validation","validationCode":"let dir = storage.updates_file_path(&info)\n    .and_then(|p| p.parent().map(Path::to_path_buf));\nif dir.as_ref().map_or(true, |d| !d.exists()) {\n    bail!(\"session directory unknown/uninitialized; initialize session before probing disk space\");\n}","typeGuard":"fn session_dir_known(storage: &Storage, info: &SessionInfo) -> bool {\n    storage.updates_file_path(info)\n        .and_then(|p| p.parent().map(|_| ()))\n        .is_some()\n}","tryCatchPattern":"match persist.probe_writable().await {\n    Err(e) if e.kind() == io::ErrorKind::NotFound => {\n        eprintln!(\"session dir unknown; re-initialize session before probing\");\n        persist = SessionPersistence::init(info, storage).await?;\n        persist.probe_writable().await?;\n    }\n    other => other?,\n}","preventionTips":["Always fully initialize a session (valid id, assigned storage path) before writability probes","Validate session info/id at construction time","Use a filesystem-backed storage config when disk-space probing matters","Log updates_file_path early to catch None-producing configs immediately"],"tags":["io","filesystem","disk-space","session","initialization"],"backgroundTag":"session-directory-unknown","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}