{"record":{"id":"3bd8d067e598f1d0","repo":"theonedev/onedev","slug":"issue-not-found-referencestring","errorCode":null,"errorMessage":"Issue not found: ${referenceString}","messagePattern":"Issue not found: (.+?)","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/ai/TodResource.java","lineNumber":469,"sourceCode":"            var summary = IssueHelper.getSummary(projectContext.currentProject, issue);\n            for (var entry: issue.getFieldInputs().entrySet()) {\n                summary.put(entry.getKey(), entry.getValue().getValues());\n            }\n            summary.put(\"link\", urlService.urlFor(issue, true));\n            summaries.add(summary);\n        }\n        return summaries;\n    }\n\n    private Issue getIssue(Project currentProject, String referenceString) {\n        var issueReference = IssueReference.of(referenceString, currentProject);\n        var issue = issueService.find(issueReference.getProject(), issueReference.getNumber());\n        if (issue != null) {\n            if (!SecurityUtils.canAccessIssue(issue))\n                throw new UnauthorizedException(\"No permission to access issue: \" + referenceString);\n            return issue;\n        } else {\n            throw new NotFoundException(\"Issue not found: \" + referenceString);\n        }\n    }\n    \n    @Path(\"/get-issue\")\n    @GET\n    public Map<String, Object> getIssueDetail(\n                @QueryParam(\"currentProject\") @NotNull String currentProjectPath, \n                @QueryParam(\"reference\") @NotNull String issueReference, \n                @QueryParam(\"forWrite\") Boolean forWrite) {\n        var subject = SecurityUtils.getSubject();\n        if (SecurityUtils.getUser(subject) == null)\n            throw new UnauthenticatedException();\n\n        var currentProject = getProject(currentProjectPath);\n        var issue = getIssue(currentProject, issueReference);                \n\n        if (forWrite != null && forWrite &&!SecurityUtils.canWriteCode(issue.getProject()))\n            throw new UnauthorizedException(\"No permission to write code in issue project\");","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/ai/TodResource.java#L451-L487","documentation":"getIssue throws NotFoundException when issueService.find returns null — no issue matches the parsed reference (project + number). The reference string is resolved against the current project, so a wrong project or a non-existent issue number yields this error.","triggerScenarios":"Calling issue/sourceIssue/targetIssue with a reference like \"#999\" or \"project#999\" where the issue number does not exist in the resolved project, or a malformed/misdirected reference that resolves to the wrong project.","commonSituations":"Hard-coded issue numbers that were deleted; referencing an issue number from a different project than currentProject; typo in the number or project path.","solutions":["Verify the issue exists: check the number in the OneDev UI under the resolved project.","Pass the correct currentProject so the reference resolves in the intended project, or use a fully-qualified reference like 'projectPath#number'.","Confirm the issue wasn't deleted or renumbered."],"exampleFix":"// before\ngetIssue(currentProject, \"#1234\")  // wrong project context\n// after\ngetIssue(currentProject, \"my-project#1234\")  // fully qualified reference","handlingStrategy":"try-catch","validationCode":"// validate reference format before calling\nfunction isValidIssueReference(ref) {\n  return /^(?:[\\w.-]+\\/)?#?\\d+$/.test(ref) || /^[\\w.-]+#\\d+$/.test(ref);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await getIssue(currentProject, ref);\n} catch (e) {\n  if (isNotFoundError(e)) return null; // treat as missing issue\n  throw e;\n}","preventionTips":["Always use fully-qualified references (projectPath#number) to avoid wrong-project resolution.","Verify issue numbers exist in the target project before batch processing.","Handle deleted/renumbered issues by re-listing issues instead of caching numbers."],"tags":["rest","not-found","issues"],"backgroundTag":"record-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"}