{"record":{"id":"8eaa0a2c1759521a","repo":"astrid-runtime/astrid","slug":"alreadyexists-8eaa0a","errorCode":"AlreadyExists","errorMessage":"private Windows directory already exists: {}","messagePattern":"private Windows directory already exists: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/astrid-core/src/platform_fs/windows/path.rs","lineNumber":338,"sourceCode":"                    target.display()\n                ),\n            )\n        })?;\n        let names = relative\n            .components()\n            .map(|component| match component {\n                Component::Normal(name) => Ok(name.to_os_string()),\n                _ => Err(io::Error::new(\n                    io::ErrorKind::InvalidInput,\n                    format!(\n                        \"private Windows directory contains a non-normal component: {}\",\n                        target.display()\n                    ),\n                )),\n            })\n            .collect::<io::Result<Vec<_>>>()?;\n        if names.is_empty() {\n            return Err(io::Error::new(\n                io::ErrorKind::AlreadyExists,\n                format!(\n                    \"private Windows directory already exists: {}\",\n                    target.display()\n                ),\n            ));\n        }\n\n        let mut created = CreatedPrivateDirectories::with_capacity(names.len());\n        let result = (|| {\n            self.verify_contract(BoundaryContract::TrustedForCreate)?;\n            let mut current = self.authority_boundary.clone();\n            for (index, name) in names.iter().enumerate() {\n                let parent = created\n                    .last_handle()\n                    .unwrap_or_else(|| self.authority_handle());\n                current.push(name);\n                let handle = create_private_directory_relative(parent, name)?;","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-core/src/platform_fs/windows/path.rs#L320-L356","documentation":"`create_private_descendants` computes the list of new directory components to create under the trusted handle; if that list is empty, there is nothing to create and the target already exists as-is. The library treats this as `AlreadyExists` rather than silently succeeding, so callers can distinguish 'created' from 'was already there'.","triggerScenarios":"Calling the create path with a target equal to the authority boundary itself (empty relative remainder), so no descendant components need creating.","commonSituations":"Idempotent startup code that re-creates the private root every launch; passing the boundary directory instead of a subdirectory; a config value defaulting to the boundary root.","solutions":["Check `target.exists()` (or match on the AlreadyExists error) and treat it as success if idempotent behavior is desired","Pass a target strictly below the boundary with at least one new component","Use a different directory name if a fresh directory is required"],"exampleFix":"// before\ncreate_private_descendants(&boundary_root)?; // nothing to create\n// after\nlet target = boundary_root.join(\"private\");\nmatch create_private_descendants(&target) {\n    Err(e) if e.kind() == io::ErrorKind::AlreadyExists => { /* reuse existing */ }\n    other => other?,\n}","handlingStrategy":"try-catch","validationCode":"if target.strip_prefix(&boundary_root).map(|r| r.as_os_str().is_empty()).unwrap_or(true) {\n    // target has no new descendants to create\n}","typeGuard":"fn has_new_components(boundary: &Path, target: &Path) -> bool {\n    target.strip_prefix(boundary).map(|r| !r.as_os_str().is_empty()).unwrap_or(false)\n}","tryCatchPattern":"match create_private_descendants(&target) {\n    Err(e) if e.kind() == io::ErrorKind::AlreadyExists => { /* reuse existing directory */ }\n    Err(e) => return Err(e),\n    Ok(()) => {}\n}","preventionTips":["Treat AlreadyExists as success in idempotent setup code","Pass targets strictly below the boundary","Log when create is called on an existing root so config defaults can be fixed"],"tags":["windows","filesystem","already-exists","idempotency"],"backgroundTag":"file-already-exists","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}