{"record":{"id":"fcea421c1a81d8a0","repo":"theonedev/onedev","slug":"storage-directory-not-found-for-project-id-s","errorCode":null,"errorMessage":"Storage directory not found for project id %s","messagePattern":"Storage directory not found for project id (.+?)","errorType":"validation","errorClass":"ExplicitException","httpStatus":null,"severity":"critical","filePath":"server-core/src/main/java/io/onedev/server/service/impl/DefaultProjectService.java","lineNumber":1775,"sourceCode":"\tpublic File getProjectDir(Long projectId) {\n\t\treturn new File(getProjectsDir(), String.valueOf(projectId));\n\t}\n\n\t@Override\n\tpublic File getSubDir(Long projectId, String subdirPath) {\n\t\treturn getSubDir(projectId, subdirPath, true);\n\t}\n\n\t@Override\n\tpublic File getSubDir(Long projectId, String subdirPath, boolean createIfNotExist) {\n\t\tFile projectDir = getProjectDir(projectId);\n\t\tif (projectDir.exists()) {\n\t\t\tFile subDir = new File(projectDir, subdirPath);\n\t\t\tif (createIfNotExist)\n\t\t\t\tFileUtils.createDir(subDir);\n\t\t\treturn subDir;\n\t\t} else {\n\t\t\tthrow new ExplicitException(\"Storage directory not found for project id \" + projectId);\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic File getGitDir(Long projectId) {\n\t\treturn getSubDir(projectId, \"git\");\n\t}\n\n\t@Override\n\tpublic File getInfoDir(Long projectId) {\n\t\treturn getSubDir(projectId, \"info\");\n\t}\n\n\t@Override\n\tpublic File getIndexDir(Long projectId) {\n\t\treturn getSubDir(projectId, \"index\");\n\t}\n","sourceCodeStart":1757,"sourceCodeEnd":1793,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/service/impl/DefaultProjectService.java#L1757-L1793","documentation":"OneDev throws this ExplicitException when a project's storage directory on disk does not exist. DefaultProjectService.getSubDir resolves the project's storage root; if the directory is missing (project storage never created, deleted, or on an unavailable volume) and createIfNotExist was not used for the root, the lookup fails with this error.","triggerScenarios":"Calling ProjectService.getSubDir(projectId, subdirPath, false) or dependent methods like getGitDir when the project's storage directory is absent on the server's file system.","commonSituations":"Project storage folder manually deleted or lost (disk failure, wrong volume mount); migrating servers without copying the site/storage directory; project row exists in the database but its files were never initialized (corrupted state); permission or mount changes making the path invisible.","solutions":["Verify the project storage directory exists under OneDev's site storage (server-core storage layout) and restore it from backup if missing.","Check that the storage volume/disk is mounted and OneDev's storage path configuration is correct.","If the project data is unrecoverable, delete the broken project and re-create/clone it so storage is re-initialized.","Restart the server after fixing mounts/paths so cached state refreshes."],"exampleFix":"// before\nFile gitDir = projectService.getGitDir(projectId); // throws if storage missing\n// after: check storage presence first\nif (!projectService.getSubDir(projectId, \"\", false).exists()) {\n    throw new IllegalStateException(\"Project storage missing; restore from backup for id \" + projectId);\n}\nFile gitDir = projectService.getGitDir(projectId);","handlingStrategy":"validation","validationCode":"// Verify project storage root exists before resolving sub-directories\nFile storageRoot = new File(storageManager.getProjectsDir(), String.valueOf(projectId));\nif (!storageRoot.isDirectory()) {\n    throw new IllegalStateException(\"Project storage missing on disk for id \" + projectId);\n}\nFile gitDir = projectService.getGitDir(projectId);","typeGuard":"function storageExists(projectService, projectId) {\n  try {\n    return projectService.getSubDir(projectId, \"\", false).isDirectory();\n  } catch (ExplicitException e) {\n    return false;\n  }\n}","tryCatchPattern":"try {\n    File gitDir = projectService.getGitDir(projectId);\n} catch (ExplicitException e) {\n    logger.error(\"Project storage missing: {}\", e.getMessage());\n    // restore from backup or re-initialize the project\n}","preventionTips":["Back up OneDev's site/storage directory before migrations","Monitor storage volume mounts and disk health","Never manually delete project folders; use the product's project-delete API","After server moves, verify each project's storage directory is present before serving traffic"],"tags":["filesystem","storage","project","missing-directory"],"backgroundTag":"directory-not-found","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}