Open eemirtekin opened 10 hours ago
I found a similar issue that was resolved. The error you're encountering might be related to the created_by_role
attribute in the MessageFile
class. Ensure that the created_by_role
parameter is passed as an instance of the CreatedByRole
enumeration, not as a plain string. This change might be necessary due to updates in version 0.10.1. Additionally, try removing your local images and deploying them again [1].
If the issue persists, you might want to check the NGINX configuration, specifically the client_max_body_size
setting, to ensure it is set correctly for your file uploads [2].
To continue talking to Dosu, mention @dosu.
Please provide the logs of the api container.
2024-10-24 09:03:46,002.002 INFO [Dummy-1] [_client.py:1038] - HTTP Request: HEAD https://bmcmededuc.biomedcentral.com/counter/pdf/10.1186/s12909-024-06026-5.pdf "HTTP/1.1 200 OK"
2024-10-24 09:03:47,575.575 ERROR [Dummy-2] [app.py:838] - Exception on /api/workflows/run [POST]
Traceback (most recent call last):
File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper
resp = resource(*args, **kwargs)
File "/app/api/.venv/lib/python3.10/site-packages/flask/views.py", line 110, in view
return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return]
File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
resp = meth(*args, **kwargs)
File "/app/api/controllers/web/wraps.py", line 19, in decorated
app_model, end_user = decode_jwt_token()
File "/app/api/controllers/web/wraps.py", line 48, in decode_jwt_token
app_model = db.session.query(App).filter(App.id == decoded["app_id"]).first()
KeyError: 'app_id'
2024-10-24 09:04:14,229.229 INFO [Dummy-3] [_client.py:1038] - HTTP Request: HEAD https://bmcmededuc.biomedcentral.com/counter/pdf/10.1186/s12909-024-06026-5.pdf "HTTP/1.1 200 OK"
2024-10-24 09:04:23,039.039 ERROR [Dummy-4] [app.py:838] - Exception on /api/workflows/run [POST]
Traceback (most recent call last):
File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper
resp = resource(*args, **kwargs)
File "/app/api/.venv/lib/python3.10/site-packages/flask/views.py", line 110, in view
return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return]
File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
resp = meth(*args, **kwargs)
File "/app/api/controllers/web/wraps.py", line 19, in decorated
app_model, end_user = decode_jwt_token()
File "/app/api/controllers/web/wraps.py", line 48, in decode_jwt_token
app_model = db.session.query(App).filter(App.id == decoded["app_id"]).first()
KeyError: 'app_id'
2024-10-24 09:13:49,213.213 INFO [Thread-7 (_generate_worker)] [_client.py:1038] - HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
2024-10-24 09:14:09,630.630 INFO [Dummy-8] [_client.py:1038] - HTTP Request: HEAD https://bmcmededuc.biomedcentral.com/counter/pdf/10.1186/s12909-024-06026-5.pdf "HTTP/1.1 200 OK"
2024-10-24 09:14:20,075.075 ERROR [Dummy-9] [app.py:838] - Exception on /api/workflows/run [POST]
Traceback (most recent call last):
File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper
resp = resource(*args, **kwargs)
File "/app/api/.venv/lib/python3.10/site-packages/flask/views.py", line 110, in view
return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return]
File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
resp = meth(*args, **kwargs)
File "/app/api/controllers/web/wraps.py", line 19, in decorated
app_model, end_user = decode_jwt_token()
File "/app/api/controllers/web/wraps.py", line 48, in decode_jwt_token
app_model = db.session.query(App).filter(App.id == decoded["app_id"]).first()
KeyError: 'app_id'
2024-10-24 09:03:46,002.002 INFO [Dummy-1] [_client.py:1038] - HTTP Request: HEAD https://bmcmededuc.biomedcentral.com/counter/pdf/10.1186/s12909-024-06026-5.pdf "HTTP/1.1 200 OK" 2024-10-24 09:03:47,575.575 ERROR [Dummy-2] [app.py:838] - Exception on /api/workflows/run [POST] Traceback (most recent call last): File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request rv = self.dispatch_request() File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper resp = resource(*args, **kwargs) File "/app/api/.venv/lib/python3.10/site-packages/flask/views.py", line 110, in view return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request resp = meth(*args, **kwargs) File "/app/api/controllers/web/wraps.py", line 19, in decorated app_model, end_user = decode_jwt_token() File "/app/api/controllers/web/wraps.py", line 48, in decode_jwt_token app_model = db.session.query(App).filter(App.id == decoded["app_id"]).first() KeyError: 'app_id' 2024-10-24 09:04:14,229.229 INFO [Dummy-3] [_client.py:1038] - HTTP Request: HEAD https://bmcmededuc.biomedcentral.com/counter/pdf/10.1186/s12909-024-06026-5.pdf "HTTP/1.1 200 OK" 2024-10-24 09:04:23,039.039 ERROR [Dummy-4] [app.py:838] - Exception on /api/workflows/run [POST] Traceback (most recent call last): File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request rv = self.dispatch_request() File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper resp = resource(*args, **kwargs) File "/app/api/.venv/lib/python3.10/site-packages/flask/views.py", line 110, in view return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request resp = meth(*args, **kwargs) File "/app/api/controllers/web/wraps.py", line 19, in decorated app_model, end_user = decode_jwt_token() File "/app/api/controllers/web/wraps.py", line 48, in decode_jwt_token app_model = db.session.query(App).filter(App.id == decoded["app_id"]).first() KeyError: 'app_id' 2024-10-24 09:13:49,213.213 INFO [Thread-7 (_generate_worker)] [_client.py:1038] - HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK" 2024-10-24 09:14:09,630.630 INFO [Dummy-8] [_client.py:1038] - HTTP Request: HEAD https://bmcmededuc.biomedcentral.com/counter/pdf/10.1186/s12909-024-06026-5.pdf "HTTP/1.1 200 OK" 2024-10-24 09:14:20,075.075 ERROR [Dummy-9] [app.py:838] - Exception on /api/workflows/run [POST] Traceback (most recent call last): File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request rv = self.dispatch_request() File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper resp = resource(*args, **kwargs) File "/app/api/.venv/lib/python3.10/site-packages/flask/views.py", line 110, in view return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request resp = meth(*args, **kwargs) File "/app/api/controllers/web/wraps.py", line 19, in decorated app_model, end_user = decode_jwt_token() File "/app/api/controllers/web/wraps.py", line 48, in decode_jwt_token app_model = db.session.query(App).filter(App.id == decoded["app_id"]).first() KeyError: 'app_id'
@dosu generate a fix for above errors
The KeyError: 'app_id'
in the decode_jwt_token
function indicates that the JWT token does not contain the app_id
key. Here are some steps to address this issue:
Check JWT Token Generation: Ensure that the JWT token is being generated with the app_id
included in its payload. The token should be structured to include app_id
as a key-value pair. Verify the part of your code where the token is created to ensure app_id
is added correctly.
Inspect Token Payload: If you have access to the token payload, inspect it to confirm that app_id
is present. This can help identify if the issue is with token generation or if it's being lost in transit.
Review Middleware/Decorators: If there are any middleware or decorators that modify the token or its payload, ensure they are not inadvertently removing or altering the app_id
.
Logging: Add logging to the decode_jwt_token
function to output the contents of the decoded
dictionary. This can help verify what keys are present in the token when the error occurs.
Token Validation: Ensure that the token is being validated correctly before reaching the decode_jwt_token
function. This includes checking for token integrity and expiration.
By following these steps, you should be able to identify and resolve the issue with the missing app_id
in the JWT token.
To continue talking to Dosu, mention @dosu.
Self Checks
Dify version
0.10.1
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
When I upload file via paste file url, I get error "500 (INTERNAL SERVER ERROR)"
✔️ Expected Behavior
No response
❌ Actual Behavior
No response