theonedev/onedev · error · NotAcceptableException

Issue not found by id: ${issueId}

Error message

Issue not found by id: ${issueId}

What it means

OneDev throws this 406 NotAcceptableException when the optional issueId in the workspace creation request does not match any existing issue. issueService.get(id) returns null for unknown ids and the endpoint rejects the request.

Source

Thrown at server-core/src/main/java/io/onedev/server/rest/resource/WorkspaceResource.java:124

		Project project = projectService.load(data.getProjectId());
		if (!SecurityUtils.canCreateWorkspaces(subject, project))
			throw new UnauthorizedException();

		if (project.getHierarchyWorkspaceSpecs().stream()
				.noneMatch(it -> it.getName().equals(data.getSpecName()))) {
			throw new NotAcceptableException("Workspace spec not found: " + data.getSpecName());
		}

		ObjectId commitId = ObjectId.fromString(data.getCommitHash());
		var commit = project.getRevCommit(commitId, false);
		if (commit == null) 
			throw new NotAcceptableException("Commit not found: " + data.getCommitHash());

		Issue issue = null;
		if (data.getIssueId() != null) {
			issue = issueService.get(data.getIssueId());
			if (issue == null)
				throw new NotAcceptableException("Issue not found by id: " + data.getIssueId());
			if (!issue.getProject().equals(project))
				throw new NotAcceptableException("Issue does not belong to specified project");
		}

		PullRequest request = null;
		if (data.getPullRequestId() != null) {
			request = pullRequestService.get(data.getPullRequestId());
			if (request == null)
				throw new NotAcceptableException("Pull request not found by id: " + data.getPullRequestId());
			if (!request.getProject().equals(project))
				throw new NotAcceptableException("Pull request does not belong to specified project");
		}

		Workspace workspace = workspaceService.create(user, project, issue, request, commitId,
				data.getBranch(), data.getSpecName(), false);
		return workspace.getId();
	}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Confirm the issue id exists: open /<project>/issues/<id> in OneDev or query the issues REST resource first.
  2. Remove the issueId field from the request payload if linking an issue is not required (it is optional).
  3. Fix automations to resolve the issue id dynamically (e.g. by issue number/key) instead of hardcoding it.

Example fix

// before
data.setIssueId(4321L); // guessed id
// after
Issue issue = OneDev.getInstance(IssueManager.class).find(project, "#123");
if (issue != null) data.setIssueId(issue.getId());
Defensive patterns

Strategy: validation

Validate before calling

if (data.getIssueId() != null && issueService.get(data.getIssueId()) == null)
    throw new IllegalArgumentException("Issue " + data.getIssueId() + " does not exist");

Type guard

Issue findIssue(Long id) {
    return id == null ? null : issueService.get(id); // null-check before use
}

Try / catch

try {
    workspaceId = createWorkspace(data);
} catch (NotAcceptableException e) {
    if (e.getMessage().startsWith("Issue not found")) data.setIssueId(null); // retry without issue link
    else throw e;
}

Prevention

When it happens

Trigger: POSTing to the workspace REST resource with data.issueId set to an id that does not exist in the database (deleted issue, typo, id from another OneDev instance).

Common situations: Automation scripts hardcoding issue ids after issues were deleted or re-imported with different ids; passing a pull-request id or build number by mistake; stale links saved in external tooling.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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