{"record":{"id":"514ad67fb36f6151","repo":"theonedev/onedev","slug":"validationexception-message-rethrown-as-badreques","errorCode":null,"errorMessage":"ValidationException message (rethrown as BadRequestException)","messagePattern":"ValidationException message \\(rethrown as BadRequestException\\)","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/job/DefaultJobService.java","lineNumber":889,"sourceCode":"\n\t\t\t\tbuild.setStatus(Build.Status.WAITING);\n\t\t\t\tbuild.setSubmitSequence(build.getSubmitSequence()+1);\n\t\t\t\tbuild.setToken(UUID.randomUUID().toString());\n\t\t\t\tbuild.setFinishDate(null);\n\t\t\t\tbuild.setPendingDate(null);\n\t\t\t\tbuild.setRetryDate(null);\n\t\t\t\tbuild.setRunningDate(null);\n\t\t\t\tbuild.setSubmitDate(new Date());\n\t\t\t\tbuild.setSubmitter(user);\n\t\t\t\tbuild.setSubmitReason(reason);\n\t\t\t\tbuild.setCanceller(null);\n\t\t\t\tbuild.setAgent(null);\n\t\t\t\tbuild.getCheckoutPaths().clear();\n\n\t\t\t\tbuildService.update(build);\n\t\t\t\tbuildSubmitted(build);\n\t\t\t} catch (ValidationException e) {\n\t\t\t\tthrow new BadRequestException(e.getMessage());\n\t\t\t} finally {\n\t\t\t\tJobAuthorizationContext.pop();\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate void resubmitRequiredDependencyBuilds(Build build, Collection<Long> resubmitBuildIds) {\n\t\tvar systemUser = userService.getSystem();\n\t\tfor (var dependence : build.getDependencies()) {\n\t\t\tvar dependency = dependence.getDependency();\n\t\t\tif (dependence.isRequireSuccessful() && !dependency.isSuccessful()) {\n\t\t\t\tresubmit(systemUser, dependency, \"Resubmitted by dependent build\", resubmitBuildIds);\n\t\t\t}\n\t\t}\n\t}\n","sourceCodeStart":871,"sourceCodeEnd":907,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/job/DefaultJobService.java#L871-L907","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the BadRequestException message — it is the validator's specific complaint — and fix that field in .onedev-buildspec.yml.","Validate the spec against the current OneDev version's schema (edit it in the UI's spec editor to get inline validation).","Restore or re-create referenced entities (executors, secrets, images, dependencies) that no longer exist.","Replace deprecated step types/properties with their current equivalents, then build a new commit."],"exampleFix":"// before: invalid step property\nsteps: !<CommandLine>\n  shell: mvn verify\n\n// after: correct property name\nsteps: !<CommandLine>\n  shellScript: mvn verify","handlingStrategy":"try-catch","validationCode":"// Validate the spec before submitting: open the spec in the OneDev UI editor\n// (inline validation) or run validateBuildSpec(project, commitId, buildSpec) server-side","typeGuard":null,"tryCatchPattern":"try {\n    jobService.restart(build);\n} catch (BadRequestException e) {\n    // e.getMessage() is the validator's complaint; fix the spec accordingly\n    log.warn(\"Spec validation failed: {}\", e.getMessage());\n}","preventionTips":["Edit .onedev-buildspec.yml via the UI editor to catch schema errors before committing","After OneDev upgrades, re-validate specs using removed/deprecated step types","Ensure referenced executors, secrets, and images still exist in settings"],"tags":["validation","build-spec","ci-pipeline","schema"],"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-14T05:17:10.506Z"}