theonedev/onedev · error · BadRequestException

ValidationException message (rethrown as BadRequestException

Error message

ValidationException message (rethrown as BadRequestException)

What it means

DefaultJobService's re-submission path validates the build spec (validateBuildSpec) inside a try block; a ValidationException from the spec validator is caught and rethrown as a BadRequestException carrying the validator's message. So this entry represents any spec-validation failure (bad step syntax, missing required fields, invalid references) detected when re-running a finished build.

Source

Thrown at server-core/src/main/java/io/onedev/server/job/DefaultJobService.java:889

				build.setStatus(Build.Status.WAITING);
				build.setSubmitSequence(build.getSubmitSequence()+1);
				build.setToken(UUID.randomUUID().toString());
				build.setFinishDate(null);
				build.setPendingDate(null);
				build.setRetryDate(null);
				build.setRunningDate(null);
				build.setSubmitDate(new Date());
				build.setSubmitter(user);
				build.setSubmitReason(reason);
				build.setCanceller(null);
				build.setAgent(null);
				build.getCheckoutPaths().clear();

				buildService.update(build);
				buildSubmitted(build);
			} catch (ValidationException e) {
				throw new BadRequestException(e.getMessage());
			} finally {
				JobAuthorizationContext.pop();
			}
			return true;
		}
		return false;
	}

	private void resubmitRequiredDependencyBuilds(Build build, Collection<Long> resubmitBuildIds) {
		var systemUser = userService.getSystem();
		for (var dependence : build.getDependencies()) {
			var dependency = dependence.getDependency();
			if (dependence.isRequireSuccessful() && !dependency.isSuccessful()) {
				resubmit(systemUser, dependency, "Resubmitted by dependent build", resubmitBuildIds);
			}
		}
	}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Read the BadRequestException message — it is the validator's specific complaint — and fix that field in .onedev-buildspec.yml.
  2. Validate the spec against the current OneDev version's schema (edit it in the UI's spec editor to get inline validation).
  3. Restore or re-create referenced entities (executors, secrets, images, dependencies) that no longer exist.
  4. Replace deprecated step types/properties with their current equivalents, then build a new commit.

Example fix

// before: invalid step property
steps: !<CommandLine>
  shell: mvn verify

// after: correct property name
steps: !<CommandLine>
  shellScript: mvn verify
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate the spec before submitting: open the spec in the OneDev UI editor
// (inline validation) or run validateBuildSpec(project, commitId, buildSpec) server-side

Try / catch

try {
    jobService.restart(build);
} catch (BadRequestException e) {
    // e.getMessage() is the validator's complaint; fix the spec accordingly
    log.warn("Spec validation failed: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Re-running a finished build whose stored BuildSpec fails validateBuildSpec — e.g., invalid job executor references, malformed step definitions, missing required step properties, or references (images, secrets, job names) that no longer resolve; ValidationException is converted at the catch in the submit/execute path.

Common situations: Spec written for an older OneDev version using since-removed step types or properties; referenced executor/secret/image deleted from settings; hand-edited spec with wrong YAML tags (!<CommandLine> etc.); plugin executor removed after upgrade.

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


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/514ad67fb36f6151. Report an issue: GitHub.