{"record":{"id":"092f2b36da42fd78","repo":"theonedev/onedev","slug":"unable-to-find-issue-value","errorCode":null,"errorMessage":"Unable to find issue: ${value}","messagePattern":"Unable to find issue: (.+?)","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/util/QueryUtils.java","lineNumber":152,"sourceCode":"\n\tpublic static ProjectScopedRevision getRevision(@Nullable Project project, String value) {\n\t\tif (project != null && !value.contains(\":\"))\n\t\t\tvalue = project.getPath() + \":\" + value;\n\t\tProjectScopedRevision revision = ProjectScopedRevision.from(value);\n\t\tif (revision != null)\n\t\t\treturn revision;\n\t\telse\n\t\t\tthrow new NotFoundException(\"Unable to find revision: \" + value);\n\t}\n\t\n\tpublic static Issue getIssue(@Nullable Project project, String value) {\n\t\tvar reference = IssueReference.of(value, project);\n\t\tvar issueService = OneDev.getInstance(IssueService.class);\n\t\tvar issue = issueService.find(reference.getProject(), reference.getNumber());\n\t\tif (issue != null)\n\t\t\treturn issue.resolveMovedTo();\n\t\telse\n\t\t\tthrow new NotFoundException(\"Unable to find issue: \" + value);\n\t}\n\t\n\tpublic static PullRequest getPullRequest(@Nullable Project project, String value) {\n\t\tvar reference = PullRequestReference.of(value, project);\n\t\tvar pullRequest = OneDev.getInstance(PullRequestService.class).find(reference.getProject(), reference.getNumber());\n\t\tif (pullRequest != null)\n\t\t\treturn pullRequest;\n\t\telse\n\t\t\tthrow new NotFoundException(\"Unable to find pull request: \" + value);\n\t}\n\t\n\tpublic static Build getBuild(@Nullable Project project, String value) {\n\t\tvar reference = BuildReference.of(value, project);\n\t\tvar build = OneDev.getInstance(BuildService.class).find(reference.getProject(), reference.getNumber());\n\t\tif (build != null)\n\t\t\treturn build;\n\t\telse\n\t\t\tthrow new NotFoundException(\"Unable to find build: \" + value);","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/util/QueryUtils.java#L134-L170","documentation":"QueryUtils.getIssue resolves an issue reference (e.g. '#123' or 'project#123') to an Issue entity via IssueService.find. If no issue with that number exists in the referenced project, a NotFoundException 'Unable to find issue' is thrown. Found issues are resolved through moved-to chains before being returned.","triggerScenarios":"Calling QueryUtils.getIssue with an issue number that does not exist in the target project; referencing '#123' without a project scope when project is null; referencing an issue in a different project than intended.","commonSituations":"Query criteria values like 'state is Open and number is #999' after issues were deleted; copied issue links from another project; issues in private projects invisible to the caller; typo in the issue number.","solutions":["Verify the issue number exists in the referenced project (check the issue URL)","Add the project scope to the reference (e.g. 'group/project#123') or pass the correct default Project","Check whether the issue was deleted or moved — getIssue follows moved-to chains, so use the new number if the original was removed","Confirm the calling user can access the project containing the issue"],"exampleFix":"// before\nIssue issue = QueryUtils.getIssue(null, \"#42\");\n// after\nIssue issue = QueryUtils.getIssue(project, \"group/my-project#42\");","handlingStrategy":"try-catch","validationCode":"if (!value.matches(\"(#\\\\d+|[^#]+#\\\\d+)\"))\n    throw new UserException(\"Issue reference must look like '#123' or 'project#123'\");","typeGuard":"boolean isIssueReference(String s) {\n    return s != null && s.matches(\"(#\\\\d+|[^#]+#\\\\d+)\");\n}","tryCatchPattern":"try {\n    Issue issue = QueryUtils.getIssue(project, value);\n} catch (NotFoundException e) {\n    logger.warn(\"Issue not found: {}\", value);\n    // skip this criterion value or notify the user\n}","preventionTips":["Always include the project scope when issues may live in other projects","Verify the number is an issue, not a PR/build number","Clean up saved queries after issues are deleted"],"tags":["issue","lookup","not-found","onedev"],"backgroundTag":"entity-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"}