{"record":{"id":"224449c0930598f5","repo":"theonedev/onedev","slug":"i-need-to-create-workspace-to-do-the-job-but-no-a","errorCode":null,"errorMessage":"I need to create workspace to do the job, but no applicable workspace spec found","messagePattern":"I need to create workspace to do the job, but no applicable workspace spec found","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/workspace/DefaultWorkspaceService.java","lineNumber":1222,"sourceCode":"\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\t\t\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t} else if (workspace.getStatus() == Workspace.Status.INACTIVE) {\n\t\t\t\t\t\t\t\tsessionService.run(() -> {\n\t\t\t\t\t\t\t\t\ttaskFailedCallback.onTaskFailed(workspaceReference);\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t} else {\n\t\t\tthrow new ExplicitException(\"I need to create workspace to do the job, but no applicable workspace spec found\");\n\t\t}\n\t}\n\n\tprivate ClusterTask<Void> newRunWorkspaceTask(WorkspaceContext context) {\n\t\treturn new ClusterTask<Void>() {\n\t\t\n\t\t\tprivate void run(WorkspaceContext context, TaskLogger workspaceLogger) {\n\t\t\t\tvar workspaceId = context.getWorkspaceId();\n\t\t\t\ttransactionService.run(() -> {\n\t\t\t\t\tvar workspace = load(workspaceId);\n\t\t\t\t\tif (!Objects.equals(workspace.getProvisionerName(), context.getProvisioner().getName())) {\n\t\t\t\t\t\tworkspace.setProvisionerName(context.getProvisioner().getName());\n\t\t\t\t\t\tupdate(workspace);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\n\t\t\t\tvar runtime = context.getProvisioner().provision(context, workspaceLogger);\n\t\t\t\tworkspaceRuntimes.put(workspaceId, runtime);","sourceCodeStart":1204,"sourceCodeEnd":1240,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/workspace/DefaultWorkspaceService.java#L1204-L1240","documentation":"Thrown by DefaultWorkspaceService when a job requires a workspace but no workspace spec in the project hierarchy matches the job's criteria (no applicable spec found among candidate projects/branches). It is an ExplicitException with a user-friendly message, indicating a configuration gap rather than an internal bug.","triggerScenarios":"A CI/CD job declares it needs a workspace (e.g. runs on a dev container/workspace-based executor) but no candidate spec in the hierarchy qualifies — specs exist but none is applicable to this job/branch, or none exists at all.","commonSituations":"Branch protection/CI setup requires workspaces but only some branches define the spec; spec criteria (image, setup commands) filtered out all candidates; job moved to a project whose ancestors lack workspace specs.","solutions":["Add a workspace spec applicable to the job's project and branch.","Widen the spec's applicability (remove restrictive branch/path conditions).","Change the job configuration to not require a workspace (use a different executor).","Verify the job runs in a project whose hierarchy includes a spec-defining project."],"exampleFix":"// before: no spec on feature branches -> exception\n// after: add .onedev-workspace.yml (or job spec) covering the branch\ntype: command\ntasks:\n- name: dev\n  commands: |\n    ./setup.sh","handlingStrategy":"validation","validationCode":"// Java\nboolean hasSpec = projectHierarchyStream()\n    .anyMatch(p -> p.getWorkspaceSpec() != null);\nif (!hasSpec)\n    throw new ExplicitException(\"Add a workspace spec before queueing workspace-dependent jobs\");","typeGuard":null,"tryCatchPattern":"try { runJobWithWorkspace(job); } catch (ExplicitException e) { if (e.getMessage().contains(\"no applicable workspace spec\")) promptUserToDefineSpec(); }","preventionTips":["Define workspace specs covering all branches CI runs on","Review spec applicability conditions when moving jobs between projects","Lint CI configs to require a workspace spec for workspace executors"],"tags":["onedev","workspace","ci-cd","missing-spec"],"backgroundTag":"missing-required-config","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"}