{"record":{"id":"cd731c94d00fd319","repo":"theonedev/onedev","slug":"unable-to-find-project-to-import-build-spec-0","errorCode":null,"errorMessage":"Unable to find project to import build spec: {0}","messagePattern":"Unable to find project to import build spec: (.+?)","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/Import.java","lineNumber":247,"sourceCode":"\t\t\t\t}\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tcontext.disableDefaultConstraintViolation();\n\t\t\tString message = e.getMessage();\n\t\t\tif (message == null) {\n\t\t\t\tlogger.error(\"Error validating build spec import\", e);\n\t\t\t\tmessage = _T(\"Failed to validate build spec import. Check server log for details\");\n\t\t\t}\n\t\t\tcontext.buildConstraintViolationWithTemplate(message).addConstraintViolation();\n\t\t\treturn false;\n\t\t}\n\t}\n\t\n\tpublic Project getProject() {\n\t\tif (project == null) {\n\t\t\tproject = OneDev.getInstance(ProjectService.class).findByPath(projectPath);\n\t\t\tif (project == null)\n\t\t\t\tthrow new ExplicitException(MessageFormat.format( _T(\"Unable to find project to import build spec: {0}\"), projectPath));\n\t\t}\n\t\treturn project;\n\t}\n\t\n\tpublic RevCommit getCommit() {\n\t\tif (commit == null) {\n\t\t\tcommit = getProject().getRevCommit(revision, false);\n\t\t\tif (commit == null) {\n\t\t\t\tString errorMessage = MessageFormat.format(\n\t\t\t\t\t\t_T(\"Unable to find commit to import build spec (import project: {0}, import revision: {1})\"),\n\t\t\t\t\t\tprojectPath, revision);\n\t\t\t\tthrow new ExplicitException(errorMessage);\n\t\t\t}\n\t\t}\n\t\treturn commit;\n\t}\n\t\n}","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/Import.java#L229-L265","documentation":"Import.getProject resolves the import's projectPath to a Project via ProjectService.findByPath. If no project exists at that path, it throws an ExplicitException because the imported build spec cannot be located without a valid project.","triggerScenarios":"getProject() called (directly or via project(), isValid(), or getCommit()) when findByPath(projectPath) returns null — the path in the `project` field of the import does not match any existing project.","commonSituations":"Typo in project path (case sensitivity, missing parent path); imported project was renamed, archived, or deleted; project exists on a different OneDev instance/tenant than assumed.","solutions":["Correct the `project` field in the import entry to the exact full path of an existing project.","Check the project list for the current name — rename it back or update the import if the project was renamed/deleted.","Verify permissions/visibility if the project exists but the current account cannot see it."],"exampleFix":"// before\nimports:\n- project: Shared/Pipelines\n  revision: main\n// after (exact existing path)\nimports:\n- project: shared/pipelines\n  revision: main","handlingStrategy":"validation","validationCode":"var project = OneDev.getInstance(ProjectService.class).findByPath(projectPath);\nif (project == null) throw new IllegalArgumentException(\"Unknown project path: \" + projectPath);","typeGuard":null,"tryCatchPattern":"try { import.getProject(); } catch (ExplicitException e) { reportBadImportPath(e.getMessage()); }","preventionTips":["Copy project paths from the project URL instead of typing them.","Grep build specs for imports when renaming/deleting projects.","Watch project audit log for renames that break downstream imports."],"tags":["project","not-found","import","onedev"],"backgroundTag":"resource-not-found","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}