{"record":{"id":"1a9d948fadb407e4","repo":"theonedev/onedev","slug":"build-spec-not-defined-import-project-0-impor","errorCode":null,"errorMessage":"Build spec not defined (import project: {0}, import revision: {1})","messagePattern":"Build spec not defined \\(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":186,"sourceCode":"\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());\n\t\t\t\tcircular.add(commit.name());\n\t\t\t\tString errorMessage = MessageFormat.format(\n\t\t\t\t\t\t_T(\"Circular build spec imports ({0})\"), circular);\n\t\t\t\tcontext.disableDefaultConstraintViolation();\n\t\t\t\tcontext.buildConstraintViolationWithTemplate(errorMessage).addConstraintViolation();\n\t\t\t\treturn false;","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/Import.java#L168-L204","documentation":"Import.getBuildSpec returns null when the imported project at the given revision defines no build spec at all (no .onedev-buildspec file). OneDev converts that null into an ExplicitException naming the import project and revision, since importing a non-existent spec cannot proceed.","triggerScenarios":"An `imports` entry in a build spec references a project/revision pair where getBuildSpec(commit) returns null — the commit has no .onedev-buildspec file, or the build spec is registered under a different path/setting.","commonSituations":"Typo in the import project path resolved to a repo without a spec; imported revision predates introduction of the build spec; repo stores its spec at a custom location and the project build-spec setting was never configured.","solutions":["Add a .onedev-buildspec file to the imported project at the referenced revision.","Point the import revision at a commit that actually contains the build spec.","If the spec lives at a custom path, set it in the imported project's Build Specs setting so getBuildSpec finds it."],"exampleFix":"// before: import revision \"old-branch\" has no spec\nimports:\n- project: shared/pipeline\n  revision: old-branch\n// after: use a revision containing .onedev-buildspec\nimports:\n- project: shared/pipeline\n  revision: main","handlingStrategy":"validation","validationCode":"// Check the target commit actually has a build spec before importing\nvar commit = project.getRevCommit(revision, false);\nif (commit == null || project.getBuildSpec(commit) == null)\n    throw new IllegalStateException(\"No build spec at \" + revision);","typeGuard":null,"tryCatchPattern":"try { import.getBuildSpec(); } catch (ExplicitException e) { fallbackToLocalSpec(e.getMessage()); }","preventionTips":["Only reference revisions you have verified contain .onedev-buildspec.","Configure the build spec path in project settings if the spec lives at a custom location.","Prefer branch/tag names over raw hashes so renames are visible in review."],"tags":["buildspec","import","missing-spec","onedev"],"backgroundTag":"file-not-found","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"}