theonedev/onedev · error · EntityNotFoundException

Unable to find issue #

Error message

Unable to find issue #{0} in project {1}

What it means

IssueDetailPage looks up the issue by number in the current project via issueService.find(); when no issue with that number exists it throws EntityNotFoundException with this message. Unlike the 'Invalid issue number' error, the parameter parsed fine — the entity simply does not exist in that project.

Solutions

  1. Verify the issue number exists in this project (check the project's issue list).
  2. Check that the URL targets the correct project; the issue may live in another project.
  3. If the issue was moved, use the original URL and OneDev will redirect via resolveMovedTo — but only if the issue itself is found.

Example fix

// before
open(projectUrl + "/~issues/" + guessedNumber);
// after
Issue issue = issueService.find(project, number);
if (issue != null) open(IssueDetailPage.paramsOf(issue));
Defensive patterns

Strategy: validation

Validate before calling

Issue issue = issueService.find(project, number);
if (issue == null) throw new IllegalArgumentException("Issue #" + number + " does not exist in " + project.getPath());

Type guard

boolean issueExists(Project p, long number) { return issueService.find(p, number) != null; }

Try / catch

try { loadIssue(number); } catch (EntityNotFoundException e) { showIssueNotFoundMessage(number); }

Prevention

When it happens

Trigger: Loading an issue detail URL whose number exceeds the project's issue count or was deleted; resolving an issue number against the wrong project.

Common situations: Issue deleted (or project history reset) while an old link/bookmark is still used; sharing a URL across projects; automated link generation using stale issue numbers after a DB migration.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/0c67016c462a8dcc. Report an issue: GitHub.

Appendix: source

Thrown at server-core/src/main/java/io/onedev/server/web/page/project/issues/detail/IssueDetailPage.java:119

		if (StringUtils.isBlank(issueNumberString)) {
			throw new RestartResponseException(ProjectIssueListPage.class, 
					ProjectIssueListPage.paramsOf(getProject(), null, 0));
		}
		
		issueModel = new LoadableDetachableModel<Issue>() {

			@Override
			protected Issue load() {
				Long issueNumber;
				try {
					issueNumber = Long.valueOf(issueNumberString);
				} catch (NumberFormatException e) {
					throw new NotAcceptableException(MessageFormat.format(_T("Invalid issue number: {0}"), issueNumberString));
				}
				
				Issue issue = issueService.find(getProject(), issueNumber);
				if (issue == null) { 
					throw new EntityNotFoundException(MessageFormat.format(_T("Unable to find issue #{0} in project {1}"), issueNumber, getProject()));
				} else {
					issue = issue.resolveMovedTo();
					issueLinkService.loadDeepLinks(issue);
					if (!issue.getProject().equals(getProject())) 
						throw new RestartResponseException(getPageClass(), paramsOf(issue));
					return issue;
				}
			}

		};
	}
	
	public Issue getIssue() {
		return issueModel.getObject();
	}
	
	@Override
	protected boolean isPermitted() {

View on GitHub (pinned to d44925c47c)