{"record":{"id":"2d7d9f75eac82e08","repo":"theonedev/onedev","slug":"job-name-is-required","errorCode":null,"errorMessage":"Job name is required","messagePattern":"Job name is required","errorType":"exception","errorClass":"io.onedev.server.exception.NotAcceptableException","httpStatus":406,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/ai/TodResource.java","lineNumber":1690,"sourceCode":"    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Path(\"/run-job\")\n    @POST\n    public Map<String, Object> runJob(\n                @QueryParam(\"currentProject\") @NotNull String currentProjectPath, \n                @NotNull @Valid Map<String, Serializable> data) {\n        var subject = SecurityUtils.getSubject();\n        var user = SecurityUtils.getUser(subject);\n\n        if (user == null)\n            throw new UnauthenticatedException();\n\n        var project = getProject(currentProjectPath);\n\n        var jobName = trimToNull((String)data.get(\"jobName\"));\n        if (jobName == null)\n            throw new NotAcceptableException(\"Job name is required\");\n\n        if (!SecurityUtils.canRunJob(subject, project, jobName))\t\t\n            throw new UnauthorizedException();\n\n        String refName;\n        var branch = trimToNull((String)data.get(\"branch\"));\n        var tag = trimToNull((String)data.get(\"tag\"));\n        var commitHash = trimToNull((String)data.get(\"commitHash\"));\n        if (commitHash != null) {\n            refName = trimToNull((String)data.get(\"refName\"));\n            if (refName == null) {\n                throw new NotAcceptableException(\"Ref name is required when commit hash is specified\");\n            }\n        } else if (branch != null) {            \n            refName = GitUtils.branch2ref(branch);\n        } else if (tag != null) {\n            refName = GitUtils.tag2ref(tag);\n        } else {","sourceCodeStart":1672,"sourceCodeEnd":1708,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/ai/TodResource.java#L1672-L1708","documentation":"The run-job endpoint validates that the request body contains a 'jobName' entry; trimToNull((String)data.get(\"jobName\")) returning null triggers NotAcceptableException('Job name is required') (HTTP 406-style validation failure). The user was authenticated but the payload is incomplete.","triggerScenarios":"POSTing to the run-job endpoint with a data map that omits 'jobName', sets it to an empty string, or sets a non-string value (e.g. a number or nested object) that the cast treats as unusable.","commonSituations":"AI tool schema drift: client sends 'job' instead of 'jobName'; whitespace-only value after trim; JSON produced programmatically with a null field omitted entirely.","solutions":["Add a non-empty 'jobName' string field to the request body.","Fix the client key name to exactly 'jobName' (case-sensitive).","Trim/validate the value before sending so it is not blank.","In client code, reject requests where !(data.jobName is a non-empty string) before calling the endpoint."],"exampleFix":"// before\nvar data = Map.of(\"branch\", \"main\"); // Job name is required\n// after\nvar data = Map.of(\"jobName\", \"build-and-test\", \"branch\", \"main\");","handlingStrategy":"validation","validationCode":"String jobName = (String) data.get(\"jobName\");\nif (jobName == null || jobName.trim().isEmpty()) {\n    throw new NotAcceptableException(\"'jobName' must be a non-empty string\");\n}","typeGuard":"function hasJobName(data) {\n  return data != null && typeof data.jobName === 'string' && data.jobName.trim().length > 0;\n}","tryCatchPattern":"try {\n    runJob(projectPath, data);\n} catch (NotAcceptableException e) {\n    if (e.getMessage().contains(\"Job name is required\")) {\n        log.error(\"Payload missing jobName; keys sent: {}\", data.keySet());\n    }\n}","preventionTips":["Validate required body fields against the tool schema before sending.","Use the exact key 'jobName' (case-sensitive).","Trim values and reject whitespace-only strings client-side.","Serialize non-string values to strings when the API expects String."],"tags":["validation","missing-parameter","build-job","onedev"],"backgroundTag":"missing-required-argument","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"}