theonedev/onedev · error · NotAcceptableException

Only inactive workspaces can be reprovisioned

Error message

Only inactive workspaces can be reprovisioned

What it means

OneDev throws this 406 NotAcceptableException from the reprovision endpoint when the workspace's status is not INACTIVE. Reprovisioning (workspaceService.reset) is only valid for workspaces that have been deprovisioned/inactive; active or provisioning workspaces must go through other operations.

Source

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

				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")
	@POST
	public Response reprovisionWorkspace(@PathParam("workspaceId") Long workspaceId) {
		Workspace workspace = workspaceService.load(workspaceId);
		if (!SecurityUtils.canModifyOrDelete(workspace))
			throw new UnauthorizedException();
		if (workspace.getStatus() != Status.INACTIVE)
			throw new NotAcceptableException("Only inactive workspaces can be reprovisioned");
		workspaceService.reset(workspace);
		return Response.ok().build();
	}

	@Api(order=500)
	@Path("/{workspaceId}")
	@DELETE
	public Response deleteWorkspace(@PathParam("workspaceId") Long workspaceId) {
		Workspace workspace = workspaceService.load(workspaceId);
		if (!SecurityUtils.canModifyOrDelete(workspace))
			throw new UnauthorizedException();
		workspaceService.delete(workspace);
		var oldAuditContent = VersionedXmlDoc.fromBean(workspace).toXML();
		auditService.audit(workspace.getProject(), "deleted workspace \""
				+ workspace.getReference().toString(workspace.getProject())
				+ "\" via RESTful API", oldAuditContent, null);
		return Response.ok().build();
	}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Check the workspace status first (GET the workspace) and only reprovision when status is INACTIVE.
  2. If the workspace is active and you want a fresh environment, delete and recreate the workspace instead.
  3. Wait for any in-progress provisioning to finish and deprovision the workspace before reprovisioning.
  4. Make automation idempotent: skip the reprovision call if status is not INACTIVE.

Example fix

// before
curl -X POST .../workspaces/42/reprovision  # unconditional
// after
status=$(curl .../workspaces/42 | jq -r .status)
[ "$status" = "INACTIVE" ] && curl -X POST .../workspaces/42/reprovision
Defensive patterns

Strategy: validation

Validate before calling

Workspace ws = workspaceService.load(workspaceId);
if (ws.getStatus() != Status.INACTIVE)
    throw new IllegalStateException("Cannot reprovision workspace in status " + ws.getStatus());

Type guard

boolean canReprovision(Workspace ws) { return ws.getStatus() == Status.INACTIVE; }

Try / catch

try {
    reprovision(workspaceId);
} catch (NotAcceptableException e) {
    if (e.getMessage().contains("Only inactive")) {
        deprovisionThenReprovision(workspaceId); // fallback path
    } else throw e;
}

Prevention

When it happens

Trigger: POSTing /workspaces/{workspaceId}/reprovision for a workspace whose Status is ACTIVE (or any non-INACTIVE value such as in the middle of provisioning).

Common situations: Double-clicking or retrying a reprovision call after it already succeeded; scripts that reprovision unconditionally without checking status first; race conditions where the workspace was reactivated between status check and call.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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