{"record":{"id":"72174817a71adf45","repo":"theonedev/onedev","slug":"ci-cd-spec-is-not-being-edited-currently","errorCode":null,"errorMessage":"CI/CD spec is not being edited currently","messagePattern":"CI/CD spec is not being edited currently","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"warning","filePath":"server-core/src/main/java/io/onedev/server/web/page/project/blob/render/renderers/buildspec/BuildSpecBlobEditPanel.java","lineNumber":181,"sourceCode":"\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tbuildSpec = BuildSpec.parse(buildSpecString.getBytes(StandardCharsets.UTF_8));\n\t\t\t\t\t\t} catch (Throwable t) {\t\t\t\t\t\n\t\t\t\t\t\t\treturn completedFuture(new ToolExecutionResult(convertToJson(Map.of(\"successful\", false, \"failReason\", \"Malformed CI/CD spec, please fix and save again\")), false));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvar violations = validator.validate(buildSpec);\n\t\t\t\t\t\tMap<String, Object> resultData;\n\t\t\t\t\t\tif (!violations.isEmpty()) {\n\t\t\t\t\t\t\tvar errorMessage = \"Failed to validate CI/CD spec, please fix errors below and save again:\\n\\n\" + \n\t\t\t\t\t\t\t\t\tJoiner.on(\"\\n\").join(violations.stream().map(it -> String.format(\"\\t-> Location: %s, Error: %s\", it.getPropertyPath(), it.getMessage())).collect(Collectors.toList()));\n\t\t\t\t\t\t\tresultData = Map.of( \"successful\", false, \"failReason\", errorMessage);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tupdateEditingContent(handler, buildSpecString.getBytes(StandardCharsets.UTF_8));\n\t\t\t\t\t\t\tresultData = Map.of(\"successful\", true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn completedFuture(new ToolExecutionResult(convertToJson(resultData), false));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new ExplicitException(\"CI/CD spec is not being edited currently\");\n\t\t\t\t\t}\n\t\t\t\t}\t\n\n\t\t\t});\t\t\t\n\t\t}\n\t\treturn tools;\n\t}\n\n}\n","sourceCodeStart":163,"sourceCodeEnd":191,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/web/page/project/blob/render/renderers/buildspec/BuildSpecBlobEditPanel.java#L163-L191","documentation":"The BuildSpecBlobEditPanel exposes an MCP-like AI tool (execute) that reads/updates the CI/CD spec being edited. If the tool is invoked when no build spec content is currently in an editing session (no editing content registered), an ExplicitException 'CI/CD spec is not being edited currently' is thrown.","triggerScenarios":"Invoking the AI assistant's CI/CD spec tool (get/update editing content) when the blob editor has no build spec open or the editing content was never initialized via updateEditingContent.","commonSituations":"AI agent calling the spec tool before the user opens the .onedev-buildspec file in the editor, or after the edit session was discarded/closed.","solutions":["Open the CI/CD spec file in the blob editor to start an editing session, then retry the tool call","Re-run the assistant action from within the active build-spec edit panel","Check that the previous editing session wasn't saved or cancelled before invoking the tool"],"exampleFix":"// before: agent calls getBuildSpecEditingContent with no spec open\n// after: user opens .onedev-buildspec in editor, then agent calls the tool","handlingStrategy":"validation","validationCode":"if (!buildSpecEditPanel.isEditingSessionActive()) {\n    openBuildSpecInEditor(); // initialize editing content first\n}","typeGuard":null,"tryCatchPattern":"try {\n    result = tool.execute();\n} catch (ExplicitException e) {\n    promptUserToOpenBuildSpec();\n}","preventionTips":["Open the CI/CD spec file in the editor before invoking assistant spec tools","Check editing-session state in agent workflows before tool calls","Retry after the user opens/saves the spec"],"tags":["ai-assistant","cicd-spec","editor-state","invalid-state"],"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-14T05:17:10.506Z"}