{"record":{"id":"595d9895638b0dae","repo":"theonedev/onedev","slug":"cannot-0-issue-1-as-it-has-workspaces","errorCode":null,"errorMessage":"Cannot {0} issue \"{1}\" as it has workspaces","messagePattern":"Cannot (.+?) issue \"(.+?)\" as it has workspaces","errorType":"http","errorClass":"NotAcceptableException","httpStatus":406,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/service/impl/DefaultIssueService.java","lineNumber":959,"sourceCode":"\t\t\tUndefinedFieldResolution resolution = new UndefinedFieldResolution();\n\t\t\tresolution.setFixType(UndefinedFieldResolution.FixType.DELETE_THIS_FIELD);\n\t\t\tresolutions.put(field, resolution);\n\t\t}\n\t\treturn resolutions;\n\t}\n\n\t\n\t@Transactional\n\t@Override\n\tpublic void delete(Issue issue) {\n\t\tcheckNoWorkspaces(issue, \"delete\");\n\t\tdao.remove(issue);\n\t\tlistenerRegistry.post(new IssueDeleted(issue));\n\t}\n\n\tprivate void checkNoWorkspaces(Issue issue, String operation) {\n\t\tif (issue.getWorkspaces().size() > 0) {\n\t\t\tthrow new NotAcceptableException(MessageFormat.format(\n\t\t\t\t\t\"Cannot {0} issue \\\"{1}\\\" as it has workspaces\",\n\t\t\t\t\toperation, issue.getReference().toString(issue.getProject())));\n\t\t}\n\t}\n\t\n\tprivate String getCacheKey(Issue issue) {\n\t\treturn getCacheKey(issue.getProject().getId(), issue.getNumber());\n\t}\n\t\n\tprivate String getCacheKey(Long projectId, Long issueNumber) {\n\t\treturn projectId + \":\" + issueNumber;\n\t}\n\n\t@Transactional\n\t@Listen\n\tpublic void on(EntityPersisted event) {\n\t\tif (event.getEntity() instanceof Issue) {\n\t\t\tIssue issue = (Issue) event.getEntity();","sourceCodeStart":941,"sourceCodeEnd":977,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/service/impl/DefaultIssueService.java#L941-L977","documentation":"DefaultIssueService.delete calls checkNoWorkspaces first: an issue with attached workspaces (running or saved dev environments) cannot be deleted because the workspaces would be orphaned. The formatted message names the operation and issue.","triggerScenarios":"Thrown at server-core/src/main/java/io/onedev/server/service/impl/DefaultIssueService.java:959 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete or detach the workspaces associated with the issue first.","Retry deletion only after issue.getWorkspaces() is empty."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}