{"record":{"id":"662b08185ea848eb","repo":"theonedev/onedev","slug":"workspace-spec-not-found-specname","errorCode":null,"errorMessage":"Workspace spec not found: ${specName}","messagePattern":"Workspace spec not found: (.+?)","errorType":"http","errorClass":"NotAcceptableException","httpStatus":406,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/rest/resource/WorkspaceResource.java","lineNumber":112,"sourceCode":"\n\t\treturn workspaceService.query(subject, null, parsedQuery, offset, count);\n\t}\n\n\t@Api(order=300, description=\"Create new workspace\")\n\t@POST\n\tpublic Long createWorkspace(@NotNull @Valid WorkspaceCreateData data) {\n\t\tvar subject = SecurityUtils.getSubject();\n\t\tvar user = SecurityUtils.getUser(subject);\n\t\tif (user == null)\n\t\t\tthrow new UnauthorizedException();\n\n\t\tProject project = projectService.load(data.getProjectId());\n\t\tif (!SecurityUtils.canCreateWorkspaces(subject, project))\n\t\t\tthrow new UnauthorizedException();\n\n\t\tif (project.getHierarchyWorkspaceSpecs().stream()\n\t\t\t\t.noneMatch(it -> it.getName().equals(data.getSpecName()))) {\n\t\t\tthrow new NotAcceptableException(\"Workspace spec not found: \" + data.getSpecName());\n\t\t}\n\n\t\tObjectId commitId = ObjectId.fromString(data.getCommitHash());\n\t\tvar commit = project.getRevCommit(commitId, false);\n\t\tif (commit == null) \n\t\t\tthrow new NotAcceptableException(\"Commit not found: \" + data.getCommitHash());\n\n\t\tIssue issue = null;\n\t\tif (data.getIssueId() != null) {\n\t\t\tissue = issueService.get(data.getIssueId());\n\t\t\tif (issue == null)\n\t\t\t\tthrow new NotAcceptableException(\"Issue not found by id: \" + data.getIssueId());\n\t\t\tif (!issue.getProject().equals(project))\n\t\t\t\tthrow new NotAcceptableException(\"Issue does not belong to specified project\");\n\t\t}\n\n\t\tPullRequest request = null;\n\t\tif (data.getPullRequestId() != null) {","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/rest/resource/WorkspaceResource.java#L94-L130","documentation":"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.","triggerScenarios":"POST /workspaces with data.specName that matches none of project.getHierarchyWorkspaceSpecs() names, for the project identified by data.projectId.","commonSituations":"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.","solutions":["List the project's hierarchy workspace specs (project settings or REST) and use an exact, existing name","Add the missing workspace spec to the project (or a parent project) in the UI","Fix the specName in WorkspaceCreateData, matching case exactly"],"exampleFix":"// before\ncreateWorkspace(token, data(specName=\"build-spec\"));\n// after\nString name = project.getHierarchyWorkspaceSpecs().get(0).getName();\ncreateWorkspace(token, data(specName=name)); // verified existing spec","handlingStrategy":"validation","validationCode":"boolean ok = getHierarchyWorkspaceSpecNames(projectId).contains(specName); if (!ok) throw new IllegalArgumentException(\"unknown spec: \" + specName);","typeGuard":null,"tryCatchPattern":"try { createWorkspace(data); } catch (NotAcceptableException e) { log.error(\"{} — available specs: {}\", e.getMessage(), listSpecNames(projectId)); }","preventionTips":["Fetch spec names from the project instead of hardcoding them","Re-check spec existence after project config changes","Match spec names exactly, including case"],"tags":["rest-api","workspace","workspace-spec"],"backgroundTag":"resource-not-found","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"}