Skip to content
Snippets Groups Projects
Commit 4dfbf7fa authored by Valentin Rigal's avatar Valentin Rigal
Browse files

Report the process ID as a Sentry tag when using task auth

parent 6401d875
No related branches found
No related tags found
1 merge request!2023Report the process ID as a Sentry tag when using task auth
......@@ -8,6 +8,7 @@ from arkindex.ponos.models import Agent, Task
from rest_framework_simplejwt.authentication import JWTAuthentication
from rest_framework_simplejwt.exceptions import InvalidToken
from rest_framework_simplejwt.settings import api_settings
from sentry_sdk import set_tag
class AgentUser(Agent):
......@@ -91,6 +92,10 @@ class TaskAuthentication(TokenAuthentication):
except ObjectDoesNotExist:
raise AuthenticationFailed('Task has no process.')
# Add the process ID to Sentry tags, to speed up troubleshooting
# by identifying if and which process is affected by the error.
set_tag("process.id", str(process.id))
if not process.creator_id or not process.creator.is_active:
# Same error message as the standard TokenAuthentication
raise AuthenticationFailed('User inactive or deleted.')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment