{"record":{"id":"052e99b2632463bf","repo":"theonedev/onedev","slug":"unauthorized","errorCode":null,"errorMessage":"Unauthorized","messagePattern":"Unauthorized","errorType":"http","errorClass":"UnauthorizedException","httpStatus":403,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/ai/TodResource.java","lineNumber":251,"sourceCode":"        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()));\n            }\n            if (!checker.getCommitScopes().isEmpty()) {\n                requirementBuilder.append(\"\\nAllowed commit scopes: \")\n                        .append(String.join(\", \", checker.getCommitScopes()));","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/ai/TodResource.java#L233-L269","documentation":"Authorization guard in getCommitMessageRequirement: a user is authenticated but lacks permission to read the requested project/branch context (e.g. cannot read code), so the commit message requirement is withheld with an authorization error. Fix: use an account with read access to the target project.","triggerScenarios":"Thrown at server-core/src/main/java/io/onedev/server/ai/TodResource.java:251 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide valid authentication for the tod API call.","Check that the access token has not expired or been revoked."],"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"}