{"record":{"id":"0229e09b8973348d","repo":"theonedev/onedev","slug":"error-validating-build-spec-project-s-commit","errorCode":null,"errorMessage":"Error validating build spec (project: %s, commit: %s, location: %s, message: %s)","messagePattern":"Error validating build spec \\(project: (.+?), commit: (.+?), location: (.+?), message: (.+?)\\)","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/job/DefaultJobService.java","lineNumber":270,"sourceCode":"\tprivate volatile IMap<String, Date> sequentialKeys;\n\n\tprivate volatile Map<String, List<JobSchedule>> branchSchedules;\n\t\n\tprivate volatile String maintenanceTaskId;\n\t\n\tprivate volatile String branchSchedulesTaskId;\n\n\tpublic Object writeReplace() throws ObjectStreamException {\n\t\treturn new ManagedSerializedForm(JobService.class);\n\t}\n\n\tprivate void validateBuildSpec(Project project, ObjectId commitId, BuildSpec buildSpec) {\n\t\tProject.push(project);\n\t\ttry {\n\t\t\tfor (ConstraintViolation<?> violation : validator.validate(buildSpec)) {\n\t\t\t\tString message = String.format(\"Error validating build spec (project: %s, commit: %s, location: %s, message: %s)\",\n\t\t\t\t\t\tproject.getPath(), commitId.name(), violation.getPropertyPath(), violation.getMessage());\n\t\t\t\tthrow new ValidationException(message);\n\t\t\t}\n\t\t} finally {\n\t\t\tProject.pop();\n\t\t}\n\t}\n\n\t@Transactional\n\t@Override\n\tpublic Build submit(User user, Project project, ObjectId commitId, String jobName, \n\t\t\t\t\t\tMap<String, List<String>> paramMap, String refName, \n\t\t\t\t\t\tPullRequest request, Issue issue, String reason) {\n\t\tLock lock = LockUtils.getLock(\"job-manager: \" + project.getId() + \"-\" + commitId.name());\n\t\ttransactionService.mustRunAfterTransaction(() -> lock.unlock());\n\n\t\tJobAuthorizationContext.push(new JobAuthorizationContext(project, commitId, request));\n\t\ttry {\n\t\t\t// Lock to guarantee uniqueness of build (by project, commit, job and parameters)\n\t\t\tlock.lockInterruptibly();","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/job/DefaultJobService.java#L252-L288","documentation":"DefaultJobService.validateBuildSpec runs bean-validation (javax validator) against the parsed .onedev-buildspec content for a commit. If any constraint violation is found (invalid job names, missing fields, bad references), a ValidationException is thrown with project, commit, the violation's property path, and its message, so the offending part of the build spec can be located.","triggerScenarios":"Submitting/building a job whose commit contains a build spec that violates schema constraints — e.g. invalid property values, missing required job fields, wrong references — detected by validator.validate(buildSpec). Called from submit, on(project/commit events), doResubmit, and cacheBranchSchedules.","commonSituations":"Hand-editing .onedev-buildspec with syntax/semantic mistakes; upgrading OneDev where new validation rules reject old specs; copy-pasting a spec from another project with project-specific references; interpolated properties producing invalid values.","solutions":["Read the 'location' and 'message' in the error to find the exact property path in the build spec and fix it.","Validate the .onedev-buildspec YAML against the current OneDev version's schema/examples.","If triggered after an upgrade, check release notes for changed/removed build spec fields and migrate.","Use the project's build spec editor in the UI instead of hand-editing to get inline validation."],"exampleFix":"// .onedev-buildspec before\njobs:\n- name: build\n  steps: []   # missing required steps content\n// after\njobs:\n- name: build\n  steps:\n  - !<CommandLineStep>\n    commands:\n    - mvn package","handlingStrategy":"try-catch","validationCode":"BuildSpec spec = project.getBuildSpec(commitId);\nif (spec != null) {\n  Set<ConstraintViolation<BuildSpec>> vs = validator.validate(spec);\n  if (!vs.isEmpty()) throw new ValidationException(vs.stream().map(v -> v.getPropertyPath()+\": \"+v.getMessage()).collect(joining(\"; \")));\n}","typeGuard":null,"tryCatchPattern":"try { jobService.submit(...); } catch (ValidationException e) { log.error(\"Build spec invalid: {}\", e.getMessage()); reportToUser(e.getMessage()); }","preventionTips":["Edit build specs via the UI editor with inline validation","Pin and review spec syntax against the installed OneDev version's docs","Test specs on a scratch branch before merging to trigger branches"],"tags":["build-spec","validation","ci"],"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"}