Jira webhook issue update error
Bug description Issue status can't be changed with Jira webhook, because of error at line https://github.com/DefectDojo/django-DefectDojo/blob/9d196df3f263df6796ba3c2deb42d78efb43cf37/dojo/jira_link/views.py#L80
It throws error if assignee is present, but doesn't have name key (in my case it has 'displayName' key instead). I'm thinking about fast fix changing the check of field existence to fix to the code below, but I also would like to add check for 'displayName' existence in case name is absent. If you have good idea on how to solve that I would appreciate.
Fast fix:
assignee_name = assignee['name'] if assignee['name'] else None
Expected behavior Status successfully changes
Deployment method (select with an X)
- [X] Docker Compose
- [ ] Kubernetes
- [ ] GoDojo
Logs
Use docker-compose logs (or similar, depending on your deployment method) to get the logs and add the relevant sections here showing the error occurring (if applicable).
[pid: 1|app: -|req: -/-] 172.28.1.104 (-) {60 vars in 1218 bytes} [Tue Aug 16 12:44:56 2022] POST /jira/webhook/******0?user_id=ug%3****&user_key=ug%3A***** => generated 145 bytes in 44 msecs (HTTP/1.0 500) 6 headers in 184 bytes (1 switches on core 1)
[pid: 1|app: -|req: -/-] 192.168.1.101 (admin) {58 vars in 1105 bytes} [Tue Aug 16 12:44:57 2022] GET /alerts/count => generated 13 bytes in 10 msecs (HTTP/1.1 200) 6 headers in 171 bytes (1 switches on core 0)
[16/Aug/2022 12:45:03] ERROR [dojo.jira_link.views:202] 'name'
Traceback (most recent call last):
File "/app/./dojo/jira_link/views.py", line 80, in webhook
assignee_name = assignee['name'] if assignee else None
KeyError: 'name'
[16/Aug/2022 12:45:03] ERROR [django.request:224] Internal Server Error: /jira/webhook/******00
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/django/views/decorators/http.py", line 40, in inner
return func(request, *args, **kwargs)
File "/app/./dojo/jira_link/views.py", line 80, in webhook
assignee_name = assignee['name'] if assignee else None
KeyError: 'name'
I can tkae this one.
@damiencarol it would be nice to add trying to get 'displayName' value, if 'name' does not exists.
Hi. Problem still persist for me in 2.15.* version (both Docker Compose / Kubernetes) There is case when there is no assignee in Jira for current task and webhook notification ends with 500 error from DefectDojo side. django-DefectDojo/dojo/jira_link/views.py
Error example:
[22/Nov/2022 13:20:54] ERROR [django.request:224] Internal Server Error: /jira/webhook/ Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "/usr/local/lib/python3.8/site-packages/django/views/decorators/http.py", line 40, in inner return func(request, *args, **kwargs) File "/app/./dojo/jira_link/views.py", line 106, in webhook jira_helper.process_resolution_from_jira(finding, resolution_id, resolution_name, assignee_name, jira_now, jissue) UnboundLocalError: local variable 'assignee_name' referenced before assignment
@damiencarol Should we reopen issue?