Hmbown/CodeWhale · error
Session goal store was not created
Error message
Session goal store {dir} was not created What it means
After attempting fs::create_dir on the goals directory (tolerating AlreadyExists), the code re-verifies the directory via checked_existing_session_goals_dir and errors with NotFound 'Session goal store ... was not created' if the check still cannot see a valid directory. This is an internal invariant failure: creation was expected to succeed (or already exist) yet the validation pass found nothing. Note checked_* also rejects symlinks, so a pre-existing symlink at the path lands here too.
Solutions
- Re-run the operation — transient races usually resolve on a second attempt
- Check for a symlink or file at the goals path; remove it so create_dir can make a real directory
- Inspect permissions on the parent directory and ensure no concurrent cleaner deletes the data dir
- If it persists, report as a bug — create_dir succeeding but the dir being absent is an environment race
Example fix
null
Defensive patterns
Strategy: retry
Try / catch
for attempt in 0..3 {
match manager.ensure_goal_store() {
Ok(()) => break,
Err(e) if attempt < 2 && e.kind() == io::ErrorKind::NotFound => {
std::thread::sleep(std::time::Duration::from_millis(200));
}
Err(e) => return Err(e.into()),
}
} Prevention
- Avoid running concurrent cleanup jobs against the data directory while the app runs
- Exclude the data directory from aggressive antivirus/sync tooling
- Remove symlinks at store paths so AlreadyExists doesn't mask an invalid entry
When it happens
Trigger: Calling ensure/create for the goal store when create_dir reports success or AlreadyExists but the subsequent symlink_metadata-based check returns None (path vanished, or path is a symlink treated as absent) — e.g. a race deletes the directory between the two calls.
Common situations: Another process concurrently cleaning the data directory; antivirus/sync tools removing freshly created dirs; a symlink existing at the path when create_dir hit AlreadyExists; filesystem permission oddities on network mounts.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- approval log has no parent
- cancelled tool result is always model-visible
- commit
- create isolated home
- credential fixture
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/1e8ee271bccb81dd.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/session_manager.rs:1334
dir.display()
),
));
}
Ok(Some(dir))
}
fn ensure_session_goals_dir(&self) -> std::io::Result<PathBuf> {
if let Some(dir) = self.checked_existing_session_goals_dir()? {
return Ok(dir);
}
let dir = self.session_goals_dir();
match fs::create_dir(&dir) {
Ok(()) => {}
Err(error) if error.kind() == io::ErrorKind::AlreadyExists => {}
Err(error) => return Err(error),
}
self.checked_existing_session_goals_dir()?.ok_or_else(|| {
io::Error::new(
io::ErrorKind::NotFound,
format!("Session goal store {} was not created", dir.display()),
)
})
}
fn validated_session_goal_path(&self, session_id: &str) -> std::io::Result<PathBuf> {
let id = self.validated_session_id(session_id)?;
Ok(self.session_goals_dir().join(format!("{id}.json")))
}
fn checked_existing_session_goal_file(path: &Path) -> std::io::Result<bool> {
let metadata = match fs::symlink_metadata(path) {
Ok(metadata) => metadata,
Err(error) if error.kind() == io::ErrorKind::NotFound => return Ok(false),
Err(error) => return Err(error),
};
if metadata.file_type().is_symlink() || !metadata.is_file() {View on GitHub (pinned to 73e0f67d83)