theonedev/onedev · error · NotAcceptableException

Issue does not belong to specified project

Error message

Issue does not belong to specified project

What it means

OneDev throws this 406 NotAcceptableException when the referenced issue exists but belongs to a project different from the project specified in the workspace creation request. A workspace can only link issues from the same project.

Source

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

			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();
	}

	@Api(order=400, description="Reprovision inactive workspace")
	@Path("/{workspaceId}/reprovision")

View on GitHub (pinned to d44925c47c)

Solutions

  1. Verify issue.getProject() equals the target project before calling the API; pick an issue from the specified project.
  2. Change the request's projectId to the project the issue actually belongs to (if that is the intended project).
  3. Drop the issueId from the payload if the linkage is not essential.
  4. Add a pre-check in tooling: resolve the issue via the project's issue list API instead of a bare global id.

Example fix

// before
Issue issue = issueService.get(data.getIssueId());
data.setProjectId(someOtherProject.getId());
// after
Issue issue = issueService.get(data.getIssueId());
if (issue != null && issue.getProject().equals(project)) {
    data.setProjectId(project.getId());
}
Defensive patterns

Strategy: validation

Validate before calling

Issue issue = issueService.get(data.getIssueId());
if (issue != null && !issue.getProject().equals(project))
    throw new IllegalArgumentException("Issue " + issue.getNumber() + " belongs to " + issue.getProject().getPath());

Type guard

boolean issueInProject(Issue issue, Project project) {
    return issue != null && issue.getProject().equals(project);
}

Prevention

When it happens

Trigger: POSTing to the workspace REST resource with project=X but issueId pointing at an issue in project Y.

Common situations: Cross-project automations that pass a global issue id without checking its project; users copying an issue link from a related project; bulk tooling that assumes issue ids are globally scoped to the chosen project.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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