{"record":{"id":"61745d645b4d81db","repo":"theonedev/onedev","slug":"authentication-required-61745d","errorCode":null,"errorMessage":"Authentication required","messagePattern":"Authentication required","errorType":"http","errorClass":"UnauthenticatedException","httpStatus":401,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/ai/TodResource.java","lineNumber":247,"sourceCode":"        return projectContext;\n    }\n\n    private Map<String, Object> getFieldProperties(FieldSpec field) {\n        var fieldProperties = new HashMap<>(IssueHelper.getFieldProperties(field));\n        fieldProperties.put(\"description\", escapeHtml5((String) fieldProperties.get(\"description\")));\n        return fieldProperties;\n    }\n\n    @Api(description = \"Get commit message requirement\")\n    @Path(\"/get-commit-message-requirement\")\n    @GET\n    @Nullable\n    public String getCommitMessageRequirement(\n                @QueryParam(\"project\") @NotNull String projectPath, \n                @QueryParam(\"branch\") @NotNull String branch) {\n        var user = SecurityUtils.getUser();\n        if (user == null)\n            throw new UnauthenticatedException();\n\n        var project = getProject(projectPath);\n        if (!SecurityUtils.canWriteCode(project))\n            throw new UnauthorizedException();\n            \n        return getCommitMessageRequirement(user, project, branch);\n    }\n\n    @Nullable\n    private String getCommitMessageRequirement(User user, Project project, String branch) {            \n        var requirementBuilder = new StringBuilder();\n        var branchProtection = project.getBranchProtection(branch, user);\n        if (branchProtection.getCommitMessageChecker() instanceof ConventionalCommitChecker checker) {\n            requirementBuilder.append(\"Commit messages should use Conventional Commits format: \")\n                    .append(\"<type>[optional (scope)][!]: <description>. Git revert messages are also allowed.\");\n            if (!checker.getCommitTypes().isEmpty()) {\n                requirementBuilder.append(\"\\nAllowed commit types: \")\n                        .append(String.join(\", \", checker.getCommitTypes()));","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/ai/TodResource.java#L229-L265","documentation":"Authentication guard on the REST endpoint /get-commit-message-requirement in TodResource: the caller has no authenticated session (SecurityUtils.getUser() is null), so the request cannot be attributed to a user and UnauthenticatedException is thrown before the project is accessed. Fix: authenticate (log in / supply valid credentials) before calling.","triggerScenarios":"Thrown at server-core/src/main/java/io/onedev/server/ai/TodResource.java:247 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Authenticate the request (login session or API access token) and retry.","Configure the tod client with valid credentials."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}