{"record":{"id":"816e78d55dee9375","repo":"theonedev/onedev","slug":"malformed-build-spec-import-project-0-import","errorCode":null,"errorMessage":"Malformed build spec (import project: {0}, import revision: {1})","messagePattern":"Malformed build spec \\(import project: (.+?), import revision: (.+?)\\)","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/Import.java","lineNumber":180,"sourceCode":"\t\t\t\t\t\tprojectPath, revision, e.getMessage());\n\t\t\t\tthrow new ExplicitException(errorMessage);\n\t\t\t}\n\t\t\tif (!subject.isPermitted(new ProjectPermission(project, new ReadCode())) \n\t\t\t\t\t&& !project.isPermittedByLoginUser(new ReadCode())) {\n\t\t\t\tString errorMessage = MessageFormat.format(\n\t\t\t\t\t\t_T(\"Code read permission is required to import build spec (import project: {0}, import revision: {1})\"), \n\t\t\t\t\t\tprojectPath, revision);\n\t\t\t\tthrow new ExplicitException(errorMessage);\n\t\t\t}\n\t\t\t\n\t\t\tRevCommit commit = getCommit();\n\t\t\ttry {\n\t\t\t\tbuildSpec = project.getBuildSpec(commit);\n\t\t\t} catch (BuildSpecParseException e) {\n\t\t\t\tString errorMessage = MessageFormat.format(\n\t\t\t\t\t\t_T(\"Malformed build spec (import project: {0}, import revision: {1})\"), \n\t\t\t\t\t\tprojectPath, revision);\n\t\t\t\tthrow new ExplicitException(errorMessage);\n\t\t\t}\n\t\t\tif (buildSpec == null) {\n\t\t\t\tString errorMessage = MessageFormat.format(\n\t\t\t\t\t\t_T(\"Build spec not defined (import project: {0}, import revision: {1})\"), \n\t\t\t\t\t\tprojectPath, revision);\n\t\t\t\tthrow new ExplicitException(errorMessage);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\treturn buildSpec;\n\t}\n\t\n\t@Override\n\tpublic boolean isValid(ConstraintValidatorContext context) {\n\t\ttry {\n\t\t\tvar commit = getCommit();\n\t\t\tif (IMPORT_CHAIN.get().contains(commit.name())) {\n\t\t\t\tList<String> circular = new ArrayList<>(IMPORT_CHAIN.get());","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/Import.java#L162-L198","documentation":"When a build spec imports another project's build spec via an `imports` entry, OneDev resolves the imported project's build spec at the given revision. If parsing that build spec fails (BuildSpecParseException), Import.getBuildSpec wraps the failure in an ExplicitException with the importing project path and revision so the user sees exactly which import is broken.","triggerScenarios":"Calling Import.getBuildSpec (via Import.buildSpec) where project.getBuildSpec(commit) throws BuildSpecParseException — i.e. the .onedev-buildspec file in the imported project at the given revision has syntax errors, unknown job/step names, or invalid YAML structure.","commonSituations":"Imported project committed a broken build spec; the referenced revision predates a fix; local edits to the build spec were committed with YAML/indentation mistakes; a step class name was mistyped or a plugin step was removed in the imported project.","solutions":["Open the imported project (projectPath in the message) at the given revision and fix the build spec syntax errors reported by its spec editor/validation.","Change the import revision to a commit where the imported project's build spec parses correctly.","Validate the imported spec standalone (project build spec page shows parse errors) before re-running the importing build."],"exampleFix":"// Imported project's .onedev-buildspec (before - bad indentation/unknown key)\njobs:\n- name: build\n  steps:\n  - !CheckoutStep\n    bol: true   # typo\n// after\njobs:\n- name: build\n  steps:\n  - !CheckoutStep\n    forceCheckout: true","handlingStrategy":"validation","validationCode":"// Before relying on an import, validate the imported spec resolves & parses\ntry {\n    var imported = new Import(importProjectPath, importRevision);\n    imported.getBuildSpec(); // throws ExplicitException on parse failure\n} catch (ExplicitException e) {\n    // surface e.getMessage() to the user\n}","typeGuard":null,"tryCatchPattern":"try { import.getBuildSpec(); } catch (ExplicitException e) { log.error(\"Broken import spec: {}\", e.getMessage()); }","preventionTips":["Validate the imported project's build spec in its editor before referencing it from imports.","Pin imports to stable tags/commits known to contain a valid spec.","Run a CI job in the imported project that validates its own spec on every push."],"tags":["buildspec","yaml","import","onedev"],"backgroundTag":"yaml-parse-error","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"}