You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Version 2.0.0-beta.2: Chat annotations Api Error #25506
The 500 INTERNAL_SERVER_ERROR is likely caused by either an incorrect endpoint or an invalid request payload. For creating chat annotations, the correct endpoint is /v1/apps/{app_id}/annotations (with the specific app_id in the URL), not /v1/apps/annotations. The JSON body should only include the fields question and answer—do not include apiKey or userId in the body. Authentication is handled via the Authorization header (Bearer token), and user context is managed internally, not by passing userId in the payload.
Recent changes also fixed routing conflicts for this endpoint, so using the correct URL and payload structure is important to avoid server errors (see implementation details). If you still get a 500 error after correcting these, check your Docker 'api' container logs for more details (docker-compose logs api) (log guidance). Also, ensure your user has editor permissions for the app.
The problem still exists and was present in 1.9.x as well.
I know how to fix it, but I don't know the cause. You can try the following approach:
curl 'http://192.168.1.246/console/api/apps/{your code}/annotations?page=1&limit=10&keyword='
-H 'authorization: Bearer {your key}' \
The problem still exists and was present in 1.9.x as well.
Although the controller accepts the App Token, the service layer implementation (api/services/annotation_service.py) calls current_account_with_tenant() for all annotation methods, which requires that the current_user is an Account and has loaded the current_tenant_id.
In the current implementation, using an App Token to call GET/POST /v1/apps/annotations will result in an error due to the absence of an Account context (current_user must be an Account instance). The update/delete interfaces explicitly assert isinstance(current_user, Account).
In other words, the annotation management of the service API does not currently support direct usage "solely with an App Token"; it requires the tenant's Account to be logged into the request context as an additional step.
The problem still exists and was present in 1.9.x as well.
in api/services/annotation_service.py
Changing @ validate_app_token to @ validate_app_token (fetch_user_arg=...) may work
Correspondingly, you also need to modify some code in other places.
-GET/v1/apps/annotations originally had 500 because it required an Account, but using only @ validate_app_token would not automatically set the Account;
I have read the Contributing Guide and Language Policy.[x] This is only for bug report, if you would like to ask a question, please head to Discussions.[x] I have searched for existing issues search for existing issues, including closed ones.[x] I confirm that I am using English to submit this report, otherwise it will be closed.[x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)[x] Please do not modify this template :) and fill in all the required fields.
body:{"message":"Internal Server Error","code":"unknown","status":500}
✔️ Expected Behavior
Normal Creation
❌ Actual Behavior
No response
The problem still exists and was present in 1.9.x as well.
Recently, I conducted some tests to confirm my judgment. Now I confirm that it is because of the annotations in annotation.py and annotation_stervice. py@ validate_app_token(fetch_user_arg=FetchUserArg(fetch_from=WhereisUserArg.QUERY)) You can modify these two files in Docker or local source code to address the issue caused by the relevant code. I have provided some illustrations below, which may be helpful to you.
I have read the Contributing Guide and Language Policy.[x] This is only for bug report, if you would like to ask a question, please head to Discussions.[x] I have searched for existing issues search for existing issues, including closed ones.[x] I confirm that I am using English to submit this report, otherwise it will be closed.[x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)[x] Please do not modify this template :) and fill in all the required fields.
body:{"message":"Internal Server Error","code":"unknown","status":500}
✔️ Expected Behavior
Normal Creation
❌ Actual Behavior
No response
This is the main area that needs to be modified. I have tested it on two devices, and you can use AI to assist in locating and modifying it. Below are screenshots of my successful API and console requests
Activity
dosubot commentedon Sep 11, 2025
The 500 INTERNAL_SERVER_ERROR is likely caused by either an incorrect endpoint or an invalid request payload. For creating chat annotations, the correct endpoint is
/v1/apps/{app_id}/annotations(with the specific app_id in the URL), not/v1/apps/annotations. The JSON body should only include the fieldsquestionandanswer—do not includeapiKeyoruserIdin the body. Authentication is handled via the Authorization header (Bearer token), and user context is managed internally, not by passinguserIdin the payload.Recent changes also fixed routing conflicts for this endpoint, so using the correct URL and payload structure is important to avoid server errors (see implementation details). If you still get a 500 error after correcting these, check your Docker 'api' container logs for more details (
docker-compose logs api) (log guidance). Also, ensure your user has editor permissions for the app.To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

quicksandznzn commentedon Sep 11, 2025
maybe this pr #24996 caused an error
dosubot commentedon Oct 12, 2025
Hi, @guoshiqiufeng. I'm Dosu, and I'm helping the Dify team manage their backlog and am marking this issue as stale.
Issue Summary:
/v1/apps/annotationsinstead of the correct endpoint/v1/apps/{app_id}/annotations.questionandanswerfields, and authentication must be done via the Authorization header.Next Steps:
Thank you for your understanding and contribution!
guoshiqiufeng commentedon Oct 13, 2025
The problem still exists and was present in 1.9.x as well.
Cursx commentedon Oct 15, 2025
I know how to fix it, but I don't know the cause. You can try the following approach:
curl 'http://192.168.1.246/console/api/apps/{your code}/annotations?page=1&limit=10&keyword='
-H 'authorization: Bearer {your key}' \
and this is my response
{
"data": [
{
"id": "d869e27c-52a0-47cd-8069-5d6e224b547a",
"question": "test",
"answer": "ok",
"hit_count": 0,
"created_at": 1760507636
},
{
"id": "31e830d7-485e-48fd-9d4b-0d0af03826b6",
"question": "this is test",
"answer": "ok",
"hit_count": 0,
"created_at": 1760507579
},
{
"id": "68eef311-7d92-49f7-8a14-0d20c518050f",
"question": "hello",
"answer": "你好",
"hit_count": 1,
"created_at": 1760499735
}
],
"has_more": false,
"limit": 10,
"total": 3,
"page": 1
}
Cursx commentedon Oct 16, 2025
Although the controller accepts the App Token, the service layer implementation (api/services/annotation_service.py) calls current_account_with_tenant() for all annotation methods, which requires that the current_user is an Account and has loaded the current_tenant_id.
In the current implementation, using an App Token to call GET/POST /v1/apps/annotations will result in an error due to the absence of an Account context (current_user must be an Account instance). The update/delete interfaces explicitly assert isinstance(current_user, Account).
In other words, the annotation management of the service API does not currently support direct usage "solely with an App Token"; it requires the tenant's Account to be logged into the request context as an additional step.
Cursx commentedon Oct 16, 2025
I think there are indeed some issues that haven't been resolved here
Cursx commentedon Oct 16, 2025
in api/services/annotation_service.py
Changing @ validate_app_token to @ validate_app_token (fetch_user_arg=...) may work
Correspondingly, you also need to modify some code in other places.
-GET/v1/apps/annotations originally had 500 because it required an Account, but using only @ validate_app_token would not automatically set the Account;
Cursx commentedon Oct 17, 2025
Recently, I conducted some tests to confirm my judgment. Now I confirm that it is because of the annotations in annotation.py and annotation_stervice. py@ validate_app_token(fetch_user_arg=FetchUserArg(fetch_from=WhereisUserArg.QUERY)) You can modify these two files in Docker or local source code to address the issue caused by the relevant code. I have provided some illustrations below, which may be helpful to you.
Cursx commentedon Oct 17, 2025
This is the main area that needs to be modified. I have tested it on two devices, and you can use AI to assist in locating and modifying it. Below are screenshots of my successful API and console requests
Cursx commentedon Oct 22, 2025
Although my previous method was able to solve this problem, there were many unreasonable modifications. Now I have probably solved this problem
fix Version 2.0.0-beta.2: Chat annotations Api Error #25506 (#27206)
fix Version 2.0.0-beta.2: Chat annotations Api Error #25506 (#27206)
feat:update latest commit (#51)
fix:update latest commits (#53)
fix:update latest commits and solve confilcts (#54)
Merge commit '71a359543413339c78daf8c892959c281f59a38d' into my-ht
fix Version 2.0.0-beta.2: Chat annotations Api Error langgenius#25506 (…