{"record":{"id":"157302a89d3de811","repo":"theonedev/onedev","slug":"reference-project-not-found-projectpath","errorCode":null,"errorMessage":"Reference project not found: <projectPath>","messagePattern":"Reference project not found: <projectPath>","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/entityreference/EntityReference.java","lineNumber":79,"sourceCode":"\t}\n\n\tpublic static EntityReference of(String type, String referenceString, @Nullable Project currentProject) {\n\t\tvar projectService = OneDev.getInstance(ProjectService.class);\n\t\tvar index = referenceString.indexOf('#');\n\t\tif (index != -1) {\n\t\t\tvar projectPath = referenceString.substring(0, index);\n\t\t\tvar number = parseReferenceNumber(referenceString.substring(index + 1));\n\t\t\tif (projectPath.length() == 0) {\n\t\t\t\tif (currentProject != null)\n\t\t\t\t\treturn EntityReference.of(type, currentProject, number);\n\t\t\t\telse\n\t\t\t\t\tthrow new ValidationException(\"Reference project not specified: \" + referenceString);\n\t\t\t} else {\n\t\t\t\tvar project = projectService.findByPath(projectPath);\n\t\t\t\tif (project != null)\n\t\t\t\t\treturn EntityReference.of(type, project, number);\n\t\t\t\telse\n\t\t\t\t\tthrow new ValidationException(\"Reference project not found: \" + projectPath);\n\t\t\t}\n\t\t}\n\t\tindex = referenceString.indexOf('-');\n\t\tif (index != -1) {\n\t\t\tvar projectKey = referenceString.substring(0, index);\n\t\t\tvar number = parseReferenceNumber(referenceString.substring(index + 1));\n\t\t\tvar project = projectService.findByKey(projectKey);\n\t\t\tif (project != null)\n\t\t\t\treturn EntityReference.of(type, project, number);\n\t\t\telse\n\t\t\t\tthrow new ValidationException(\"Reference project not found with key: \" + projectKey);\n\t\t}\n\t\ttry {\n\t\t\tvar number = Long.valueOf(referenceString);\n\t\t\tif (currentProject != null)\n\t\t\t\treturn EntityReference.of(type, currentProject, number);\n\t\t\telse\n\t\t\t\tthrow new ValidationException(\"Reference project not specified: \" + referenceString);","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/entityreference/EntityReference.java#L61-L97","documentation":"EntityReference.of resolves the 'path#number' form by looking up projectService.findByPath(projectPath). If no project exists with that path, a ValidationException 'Reference project not found' is thrown. The reference syntax is valid but the named project does not exist (or is not visible).","triggerScenarios":"Calling EntityReference.of(type, \"some/path#123\", ...) where findByPath(\"some/path\") returns null — misspelled path, deleted/renamed project, or path containing the wrong case/segment.","commonSituations":"Renamed or deleted projects breaking old references in issue text/links; typos in project path in markdown references; cross-project references to private projects.","solutions":["Correct the project path in the reference string to an existing project's path.","Verify the project still exists and was not renamed or deleted.","Check whether the target project is accessible (permissions/visibility) in the current context.","Use the project key form (\"KEY-123\") if the path is unknown."],"exampleFix":"// before\nEntityReference.of(\"issue\", \"old-proj#12\", null);\n// after\nEntityReference.of(\"issue\", \"renamed-proj#12\", null);","handlingStrategy":"validation","validationCode":"int i = referenceString.indexOf('#');\nString path = i > 0 ? referenceString.substring(0, i) : null;\nif (path != null && projectService.findByPath(path) == null)\n    throw new IllegalArgumentException(\"Unknown project path: \" + path);","typeGuard":null,"tryCatchPattern":"try {\n    EntityReference ref = EntityReference.of(\"issue\", input, currentProject);\n} catch (ValidationException e) {\n    if (e.getMessage().startsWith(\"Reference project not found:\")) {\n        // suggest existing project paths to the user\n    }\n}","preventionTips":["Autocomplete/validate project paths in UIs that accept references.","Re-verify stored references after project renames or deletions.","Confirm the project path is correct before embedding it in documentation or issue text.","Consider using project keys, which are more stable than paths, for references."],"tags":["entity-reference","project-not-found","validation"],"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-14T05:17:10.506Z"}