{"record":{"id":"8ce6a9d0e4a33c7f","repo":"theonedev/onedev","slug":"unauthenticated","errorCode":null,"errorMessage":"Unauthenticated","messagePattern":"Unauthenticated","errorType":"http","errorClass":"UnauthenticatedException","httpStatus":401,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/ai/TodResource.java","lineNumber":328,"sourceCode":"    public String getIssueQueryDescription() {\n        if (SecurityUtils.getUser() == null)\n            throw new UnauthenticatedException();\n        return escapeHtml5(QueryDescriptions.getIssueQueryDescription());\n    }\n\n    @Path(\"/get-build-query-description\")\n    @GET\n    public String getBuildQueryDescription() {\n        if (SecurityUtils.getUser() == null)\n            throw new UnauthenticatedException();\n        return escapeHtml5(QueryDescriptions.getBuildQueryDescription());\n    }\n\n    @Path(\"/get-pull-request-query-description\")\n    @GET\n    public String getPullRequestQueryDescription() {\n        if (SecurityUtils.getUser() == null)\n            throw new UnauthenticatedException();\n        return escapeHtml5(QueryDescriptions.getPullRequestQueryDescription());\n    }\n\n    @Path(\"/get-project-query-description\")\n    @GET\n    public String getProjectQueryDescription() {\n        if (SecurityUtils.getUser() == null)\n            throw new UnauthenticatedException();\n        return escapeHtml5(QueryDescriptions.getProjectQueryDescription());\n    }\n\n    @Path(\"/get-valid-issue-fields\")\n    @GET\n    public Map<String, Object> getValidIssueFields() {\n        if (SecurityUtils.getUser() == null)\n            throw new UnauthenticatedException();\n        var issueFields = new HashMap<String, Object>();\n        for (var field: settingService.getIssueSetting().getFieldSpecs()) {","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/ai/TodResource.java#L310-L346","documentation":"This endpoint returns a description of pull request query syntax for AI tooling. Like the other TodResource query-description endpoints, it throws UnauthenticatedException when SecurityUtils.getUser() is null, i.e. the request carries no authenticated user.","triggerScenarios":"GET /get-pull-request-query-description without a valid logged-in session or credentials.","commonSituations":"An AI agent invoking the PR-query-description tool anonymously; expired session; missing Authorization header when calling from external code.","solutions":["Send authentication with the request (login session cookie, basic auth, or access token).","Re-authenticate if the previous session expired, then retry the call.","Confirm the client (AI tool runner) is configured with OneDev credentials/URL that include authentication.","Check server logs to confirm the request arrives without a user principal, indicating the client is not sending cookies/tokens."],"exampleFix":"// before\nfetch(base + '/~ai/get-pull-request-query-description');\n// after\nfetch(base + '/~ai/get-pull-request-query-description', { headers: { Authorization: 'Bearer ' + token } });","handlingStrategy":"validation","validationCode":"if (!authClient) throw new Error('get-pull-request-query-description requires an authenticated client');","typeGuard":"const isAuthError = (e) => e?.status === 401 || /unauthenticated/i.test(e?.message ?? '');","tryCatchPattern":"try { return await client.get('/~ai/get-pull-request-query-description'); } catch (e) { if (isAuthError(e)) { await client.login(creds); return client.get('/~ai/get-pull-request-query-description'); } throw e; }","preventionTips":["Use one persistent authenticated HTTP client for all AI tool calls","Check session validity before batch tool invocations","Use long-lived access tokens for automation"],"tags":["rest","authentication","http"],"backgroundTag":"authentication-required","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}