{"record":{"id":"069d72c4b2edf81f","repo":"Hmbown/CodeWhale","slug":"session-id-trimmed-collides-with-a-reserved-se","errorCode":null,"errorMessage":"Session id '{trimmed}' collides with a reserved sessions file","messagePattern":"Session id '(.+?)' collides with a reserved sessions file","errorType":"validation","errorClass":"InvalidInput","httpStatus":null,"severity":"error","filePath":"crates/tui/src/session_manager.rs","lineNumber":1232,"sourceCode":"    fn validated_session_id<'a>(&self, id: &'a str) -> std::io::Result<&'a str> {\n        let trimmed = id.trim();\n        if trimmed.is_empty() {\n            return Err(std::io::Error::new(\n                std::io::ErrorKind::InvalidInput,\n                \"Session id cannot be empty\",\n            ));\n        }\n        if !trimmed\n            .chars()\n            .all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')\n        {\n            return Err(std::io::Error::new(\n                std::io::ErrorKind::InvalidInput,\n                format!(\"Invalid session id '{id}'\"),\n            ));\n        }\n        if trimmed == SESSION_BOOT_OWNERS_STEM {\n            return Err(std::io::Error::new(\n                std::io::ErrorKind::InvalidInput,\n                format!(\"Session id '{trimmed}' collides with a reserved sessions file\"),\n            ));\n        }\n        Ok(trimmed)\n    }\n\n    fn validated_session_path(&self, id: &str) -> std::io::Result<PathBuf> {\n        let trimmed = self.validated_session_id(id)?;\n        Ok(self.sessions_dir.join(format!(\"{trimmed}.json\")))\n    }\n\n    fn checkpoints_dir(&self) -> PathBuf {\n        self.sessions_dir.join(\"checkpoints\")\n    }\n\n    fn session_goals_dir(&self) -> PathBuf {\n        self.sessions_dir.join(SESSION_GOALS_DIR)","sourceCodeStart":1214,"sourceCodeEnd":1250,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/session_manager.rs#L1214-L1250","documentation":"Input validation in validated_session_id (session_manager.rs). After rejecting empty ids and non-alphanumeric characters, the trimmed id is checked against reserved names used by the sessions directory metadata (such as the sessions index file); an id matching a reserved sessions filename is refused with InvalidInput because creating a session with that id would collide with the reserved file on disk and corrupt session storage.","triggerScenarios":"Passing a session id whose trimmed value exactly equals the reserved stem (e.g. a name matching the boot owners registry file name).","commonSituations":"Programmatically generating ids from generic words that happen to match the reserved stem; tests reusing a reserved name.","solutions":["Choose a different session id that does not match the reserved stem","Add a distinguishing prefix/suffix (e.g. a timestamp or random token) to generated ids","Check the constant SESSION_BOOT_OWNERS_STEM in session_manager.rs and exclude it in your id generator"],"exampleFix":"// before\nlet id = SESSION_BOOT_OWNERS_STEM; // collides\n// after\nlet id = format!(\"session-{}\", SESSION_BOOT_OWNERS_STEM);","handlingStrategy":"validation","validationCode":"if id.trim() == SESSION_BOOT_OWNERS_STEM { return Err(anyhow!(\"reserved session id\")); }","typeGuard":"fn is_reserved_id(id: &str) -> bool { id.trim() == SESSION_BOOT_OWNERS_STEM }","tryCatchPattern":null,"preventionTips":["Prefix generated session ids to avoid reserved stems","Keep a set of reserved names and check in your id generator","Do not name sessions after internal store files"],"tags":["validation","session","naming-collision"],"backgroundTag":"invalid-identifier-format","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}