theonedev/onedev · error · ValidationException
Error validating build spec (project: %s, commit: %s, locati
Error message
Error validating build spec (project: %s, commit: %s, location: %s, message: %s)
What it means
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.
Source
Thrown at server-core/src/main/java/io/onedev/server/job/DefaultJobService.java:270
private volatile IMap<String, Date> sequentialKeys;
private volatile Map<String, List<JobSchedule>> branchSchedules;
private volatile String maintenanceTaskId;
private volatile String branchSchedulesTaskId;
public Object writeReplace() throws ObjectStreamException {
return new ManagedSerializedForm(JobService.class);
}
private void validateBuildSpec(Project project, ObjectId commitId, BuildSpec buildSpec) {
Project.push(project);
try {
for (ConstraintViolation<?> violation : validator.validate(buildSpec)) {
String message = String.format("Error validating build spec (project: %s, commit: %s, location: %s, message: %s)",
project.getPath(), commitId.name(), violation.getPropertyPath(), violation.getMessage());
throw new ValidationException(message);
}
} finally {
Project.pop();
}
}
@Transactional
@Override
public Build submit(User user, Project project, ObjectId commitId, String jobName,
Map<String, List<String>> paramMap, String refName,
PullRequest request, Issue issue, String reason) {
Lock lock = LockUtils.getLock("job-manager: " + project.getId() + "-" + commitId.name());
transactionService.mustRunAfterTransaction(() -> lock.unlock());
JobAuthorizationContext.push(new JobAuthorizationContext(project, commitId, request));
try {
// Lock to guarantee uniqueness of build (by project, commit, job and parameters)
lock.lockInterruptibly();View on GitHub (pinned to d44925c47c)
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.
Example fix
// .onedev-buildspec before
jobs:
- name: build
steps: [] # missing required steps content
// after
jobs:
- name: build
steps:
- !<CommandLineStep>
commands:
- mvn package Defensive patterns
Strategy: try-catch
Validate before calling
BuildSpec spec = project.getBuildSpec(commitId);
if (spec != null) {
Set<ConstraintViolation<BuildSpec>> vs = validator.validate(spec);
if (!vs.isEmpty()) throw new ValidationException(vs.stream().map(v -> v.getPropertyPath()+": "+v.getMessage()).collect(joining("; ")));
} Try / catch
try { jobService.submit(...); } catch (ValidationException e) { log.error("Build spec invalid: {}", e.getMessage()); reportToUser(e.getMessage()); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- This build is not authorized to sync to project:
- Loopback address not allowed for target docker image of push
- Step template not found:
- Invalid build id/number
- Build spec not defined (project: %s, commit: %s)
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/0229e09b8973348d.
Report an issue: GitHub.