theonedev/onedev · error · ValidationException

Error validating imported build spec (import project: %s, im

Error message

Error validating imported build spec (import project: %s, import revision: %s, location: %s, message: %s)

What it means

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.

Source

Thrown at server-core/src/main/java/io/onedev/server/buildspec/Import.java:220

				context.disableDefaultConstraintViolation();
				context.buildConstraintViolationWithTemplate(errorMessage).addConstraintViolation();
				return false;
			} else {
				IMPORT_CHAIN.get().push(commit.name());
				try {
					Validator validator = OneDev.getInstance(Validator.class);
					BuildSpec buildSpec = getBuildSpec();
					JobAuthorizationContext.push(new JobAuthorizationContext(getProject(), getCommit(), null));
					try {
						for (int i = 0; i < buildSpec.getImports().size(); i++) {
							Import aImport = buildSpec.getImports().get(i);
							for (ConstraintViolation<Import> violation : validator.validate(aImport)) {
								String location = "imports[" + i + "]";
								if (violation.getPropertyPath().toString().length() != 0)
									location += "." + violation.getPropertyPath();
								String message = String.format("Error validating imported build spec (import project: %s, import revision: %s, location: %s, message: %s)",
										projectPath, revision, location, violation.getMessage());
								throw new ValidationException(message);
							}
						}
						return true;
					} finally {
						JobAuthorizationContext.pop();
					}
				} finally {
					IMPORT_CHAIN.get().pop();
				}
			}
		} catch (Exception e) {
			context.disableDefaultConstraintViolation();
			String message = e.getMessage();
			if (message == null) {
				logger.error("Error validating build spec import", e);
				message = _T("Failed to validate build spec import. Check server log for details");
			}
			context.buildConstraintViolationWithTemplate(message).addConstraintViolation();

View on GitHub (pinned to d44925c47c)

Solutions

  1. Fix the field named in the location/message (e.g. imports[0].revision must not be empty).
  2. Open the build spec in the editor — it surfaces the same validation errors interactively — and correct them before committing.
  3. If a new OneDev version introduced the rule, update the import configuration to satisfy the new constraint.

Example fix

// before
imports:
- project: shared/pipeline
  revision:
// after
imports:
- project: shared/pipeline
  revision: main
Defensive patterns

Strategy: validation

Validate before calling

// Run bean validation yourself before committing the spec
Set<ConstraintViolation<Import>> violations = validator.validate(importEntry);
if (!violations.isEmpty()) violations.forEach(v -> System.out.println(v.getPropertyPath() + ": " + v.getMessage()));

Try / catch

try { specValidator.validate(buildSpec); } catch (ValidationException e) { showSpecEditorError(e.getMessage()); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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/9dd6f864d2e09640. Report an issue: GitHub.