theonedev/onedev · error · NotAcceptableException

Workspace spec not found: ${specName}

Error message

Workspace spec not found: ${specName}

What it means

createWorkspace validates that the requested specName exists among the target project's hierarchy workspace specs; if not, it throws NotAcceptableException 'Workspace spec not found: <name>'. Workspace specs are defined in the project tree (inherited from parent projects), and the workspace must be created against one of them.

Source

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

		return workspaceService.query(subject, null, parsedQuery, offset, count);
	}

	@Api(order=300, description="Create new workspace")
	@POST
	public Long createWorkspace(@NotNull @Valid WorkspaceCreateData data) {
		var subject = SecurityUtils.getSubject();
		var user = SecurityUtils.getUser(subject);
		if (user == null)
			throw new UnauthorizedException();

		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) {

View on GitHub (pinned to d44925c47c)

Solutions

  1. List the project's hierarchy workspace specs (project settings or REST) and use an exact, existing name
  2. Add the missing workspace spec to the project (or a parent project) in the UI
  3. Fix the specName in WorkspaceCreateData, matching case exactly

Example fix

// before
createWorkspace(token, data(specName="build-spec"));
// after
String name = project.getHierarchyWorkspaceSpecs().get(0).getName();
createWorkspace(token, data(specName=name)); // verified existing spec
Defensive patterns

Strategy: validation

Validate before calling

boolean ok = getHierarchyWorkspaceSpecNames(projectId).contains(specName); if (!ok) throw new IllegalArgumentException("unknown spec: " + specName);

Try / catch

try { createWorkspace(data); } catch (NotAcceptableException e) { log.error("{} — available specs: {}", e.getMessage(), listSpecNames(projectId)); }

Prevention

When it happens

Trigger: POST /workspaces with data.specName that matches none of project.getHierarchyWorkspaceSpecs() names, for the project identified by data.projectId.

Common situations: Spec renamed or deleted in the project after the automation was written; caller assumed a spec from a different project; typo or case mismatch in the spec name; workspace moved to a project that doesn't inherit the spec.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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