{"record":{"id":"9533482af93d13e7","repo":"clockworklabs/SpacetimeDB","slug":"failed-to-get-file-type-for-template-file-err","errorCode":null,"errorMessage":"Failed to get file_type for template file {}: {err:#?}","messagePattern":"Failed to get file_type for template file (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/build.rs","lineNumber":356,"sourceCode":"/// Get all the paths of files within `root_dir`,\n/// transform them into paths relative to `repo_root`,\n/// and insert them into `out`.\nfn ls_recursively(root_dir: &Path, repo_root: &Path, out: &mut Vec<PathBuf>) {\n    for dir_ent in std::fs::read_dir(root_dir).unwrap_or_else(|err| {\n        panic!(\n            \"Failed to read_dir from template directory {}: {err:#?}\",\n            root_dir.display()\n        )\n    }) {\n        let dir_ent = dir_ent.unwrap_or_else(|err| {\n            panic!(\n                \"Got error during read_dir from template directory {}: {err:#?}\",\n                root_dir.display(),\n            )\n        });\n        let file_path = dir_ent.path();\n        let file_type = dir_ent.file_type().unwrap_or_else(|err| {\n            panic!(\n                \"Failed to get file_type for template file {}: {err:#?}\",\n                file_path.display(),\n            )\n        });\n        if file_type.is_dir() {\n            ls_recursively(&file_path, repo_root, out);\n        } else {\n            out.push(make_repo_root_relative(&file_path, repo_root));\n        }\n    }\n}\n\n/// Treat `relative_path` as a relative path within the repo root's templates directory\n/// and transform it into an absolute, canonical path.\nfn get_full_path_within_manifest_dir(relative_path: &Path, _manifest_dir: &Path) -> PathBuf {\n    let repo_root = get_repo_root();\n    let full_path = repo_root.join(\"templates\").join(relative_path);\n","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/build.rs#L338-L374","documentation":"Build-time panic in crates/cli/build.rs: `dir_ent.file_type()` failed for an entry discovered while recursively listing a templates directory. Deciding whether to recurse (directory) or record (file) requires the entry's type; if the underlying stat call fails — dangling symlink, entry deleted between listing and stat, or I/O error — the enumeration panics rather than misclassifying the file.","triggerScenarios":"A symlink inside templates/ whose target no longer exists; files being created/deleted by another process during the cargo build; permission or filesystem errors preventing stat of an entry.","commonSituations":"Broken symlinks committed or left behind in templates/; builds racing with git operations or generators; unusual filesystems (some FUSE mounts) that fail file_type for special entries.","solutions":["Locate unreadable entries: `find templates -xtype l -o ! -readable` and remove or repair them.","Ensure nothing mutates templates/ during the build; re-run cargo afterwards.","Check the mount health if templates live on FUSE/NFS — building from a local copy avoids it.","Restore any deleted target of a symlink (`git checkout -- templates`) if the link is intentional."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Detect entries whose type cannot be determined (dangling symlinks):\nfind templates -xtype l -o ! -readable","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Commit real files, not symlinks, under templates/.","Ensure build-user has read+execute on every templates subdirectory.","Re-run builds after cleaning up broken links instead of ignoring transient stat failures."],"tags":["spacetimedb","build-script","filesystem","symlink","stat-failed"],"backgroundTag":"directory-read-failed","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}