{"record":{"id":"0210d94796f3f57f","repo":"theonedev/onedev","slug":"this-workspace-is-provisioned-on-agent-previously-0210d9","errorCode":null,"errorMessage":"This workspace is provisioned on agent previously, and cannot be reprovisioned via server shell","messagePattern":"This workspace is provisioned on agent previously, and cannot be reprovisioned via server shell","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-plugin/server-plugin-provisioner-servershell/src/main/java/io/onedev/server/plugin/provisioner/servershell/ServerShellProvisioner.java","lineNumber":249,"sourceCode":"\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic String getPortHost() {\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\t\t\t\n\t\t};\n\t}\n\n\tprotected int getConcurrencyNumber() {\n\t\treturn concurrency != null ? concurrency : 0;\n\t}\n\n\t@Override\n\tpublic <T> Future<T> submitTask(@Nullable String pinnedServerAddress, @Nullable Long pinnedAgentId,\n\t\t\t\t\t\t ClusterTask<T> task, TaskLogger logger) {\n\t\tif (pinnedAgentId != null) {\n\t\t\tthrow new ExplicitException(\"\"\"\n\t\t\t\tThis workspace is provisioned on agent previously, \\\n\t\t\t\tand cannot be reprovisioned via server shell\"\"\");\n\t\t}\n\t\tlogger.log(\"Pending resource allocation...\");\n\t\treturn getResourceService().submitServerTask(\n\t\t\t\tpinnedServerAddress, getName(), getConcurrencyNumber(), 1, task);\n\t}\n\n\t@Override\n\tpublic void deleteWorkspace(Long projectId, Long workspaceNumber, String pinnedServer, Long pinnedAgentId) {\n\t\tServerProvisionerUtils.deleteWorkspace(projectId, workspaceNumber, pinnedServer);\n\t}\n\n\t@Override\n\tpublic boolean isApplicable(Project project) {\n\t\treturn WildcardUtils.matchPath(getApplicableProjects(), project.getPath());\n\t}\n","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-plugin/server-plugin-provisioner-servershell/src/main/java/io/onedev/server/plugin/provisioner/servershell/ServerShellProvisioner.java#L231-L267","documentation":"ServerShellProvisioner.submitTask() throws when the cluster task is pinned to an agent (pinnedAgentId != null). Workspaces previously provisioned on an agent cannot be re-provisioned through the server shell path; the provisioner only supports server-pinned or unpinned tasks. This is an intentional state restriction (invalid state transition) between agent-based and server-shell provisioning.","triggerScenarios":"submitTask() invoked with a non-null pinnedAgentId — typically when a workspace recorded as agent-provisioned is being reprovisioned after the agent/provisioner was switched to server shell.","commonSituations":"Re-running a job whose workspace was originally provisioned by a docker/agent provisioner but is now assigned to a Server Shell agent; agent pool reconfiguration without clearing the workspace's recorded provisioning.","solutions":["Clear/reset the workspace so it is provisioned fresh via server shell (remove the old workspace and its recorded agent pin)","Reassign the job back to an agent-based (e.g. docker) provisioner matching the original provisioning","Recreate the agent/pool configuration so the pin no longer points to a removed agent"],"exampleFix":"// before: reusing stale agent-pinned workspace on server shell\n// after: reset workspace\nproject.build.resetWorkspace(); // or delete workspace then re-run job","handlingStrategy":"validation","validationCode":"if (workspace.getProvisionedAgentId() != null) throw new IllegalStateException(\"Reset workspace before server-shell reprovisioning\");","typeGuard":null,"tryCatchPattern":"try { provisioner.submitTask(addr, agentId, task, logger); } catch (ExplicitException e) { /* reset workspace or reassign to agent provisioner */ }","preventionTips":["Reset or delete workspaces when changing an agent's provisioner from agent-based to server shell","Avoid reusing agent-pinned workspaces across provisioner types","Document that server shell cannot reprovision agent-provisioned workspaces"],"tags":["ci","provisioner","state","agent"],"backgroundTag":"invalid-state-transition","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}