{"record":{"id":"9dd6f864d2e09640","repo":"theonedev/onedev","slug":"error-validating-imported-build-spec-import-proje","errorCode":null,"errorMessage":"Error validating imported build spec (import project: %s, import revision: %s, location: %s, message: %s)","messagePattern":"Error validating imported build spec \\(import project: (.+?), import revision: (.+?), location: (.+?), message: (.+?)\\)","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/Import.java","lineNumber":220,"sourceCode":"\t\t\t\tcontext.disableDefaultConstraintViolation();\n\t\t\t\tcontext.buildConstraintViolationWithTemplate(errorMessage).addConstraintViolation();\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\tIMPORT_CHAIN.get().push(commit.name());\n\t\t\t\ttry {\n\t\t\t\t\tValidator validator = OneDev.getInstance(Validator.class);\n\t\t\t\t\tBuildSpec buildSpec = getBuildSpec();\n\t\t\t\t\tJobAuthorizationContext.push(new JobAuthorizationContext(getProject(), getCommit(), null));\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfor (int i = 0; i < buildSpec.getImports().size(); i++) {\n\t\t\t\t\t\t\tImport aImport = buildSpec.getImports().get(i);\n\t\t\t\t\t\t\tfor (ConstraintViolation<Import> violation : validator.validate(aImport)) {\n\t\t\t\t\t\t\t\tString location = \"imports[\" + i + \"]\";\n\t\t\t\t\t\t\t\tif (violation.getPropertyPath().toString().length() != 0)\n\t\t\t\t\t\t\t\t\tlocation += \".\" + violation.getPropertyPath();\n\t\t\t\t\t\t\t\tString message = String.format(\"Error validating imported build spec (import project: %s, import revision: %s, location: %s, message: %s)\",\n\t\t\t\t\t\t\t\t\t\tprojectPath, revision, location, violation.getMessage());\n\t\t\t\t\t\t\t\tthrow new ValidationException(message);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tJobAuthorizationContext.pop();\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tIMPORT_CHAIN.get().pop();\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tcontext.disableDefaultConstraintViolation();\n\t\t\tString message = e.getMessage();\n\t\t\tif (message == null) {\n\t\t\t\tlogger.error(\"Error validating build spec import\", e);\n\t\t\t\tmessage = _T(\"Failed to validate build spec import. Check server log for details\");\n\t\t\t}\n\t\t\tcontext.buildConstraintViolationWithTemplate(message).addConstraintViolation();","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/Import.java#L202-L238","documentation":"Import.isValid runs bean validation on the imported build spec within the job authorization context. If javax.validation reports any ConstraintViolation on the Import (or its imported spec), OneDev throws a ValidationException embedding the project, revision, property location, and the violation message.","triggerScenarios":"Calling Import.isValid during build spec validation when validator.validate(aImport) yields violations — e.g. empty/missing projectPath or revision on the import, or invalid nested spec content at a given imports[i] location.","commonSituations":"Import entry saved without a required field (revision blank); imported spec violates its own constraints (bad param names, missing job name); after upgrading OneDev, new validation rules reject previously accepted import configs.","solutions":["Fix the field named in the location/message (e.g. imports[0].revision must not be empty).","Open the build spec in the editor — it surfaces the same validation errors interactively — and correct them before committing.","If a new OneDev version introduced the rule, update the import configuration to satisfy the new constraint."],"exampleFix":"// before\nimports:\n- project: shared/pipeline\n  revision:\n// after\nimports:\n- project: shared/pipeline\n  revision: main","handlingStrategy":"validation","validationCode":"// Run bean validation yourself before committing the spec\nSet<ConstraintViolation<Import>> violations = validator.validate(importEntry);\nif (!violations.isEmpty()) violations.forEach(v -> System.out.println(v.getPropertyPath() + \": \" + v.getMessage()));","typeGuard":null,"tryCatchPattern":"try { specValidator.validate(buildSpec); } catch (ValidationException e) { showSpecEditorError(e.getMessage()); }","preventionTips":["Use the build spec editor's live validation before committing.","Fill every required import field (project, revision) when authoring imports.","After OneDev upgrades, re-validate existing specs — new constraints may apply."],"tags":["validation","buildspec","import","bean-validation"],"backgroundTag":"schema-validation-failed","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"}