Skip to content

Conversation

@Maffooch
Copy link
Contributor

@Maffooch Maffooch commented Oct 29, 2025

Eliminate prefetched tags to prevent issues with celery delegation during finding closure operations.

[29/Oct/2025 17:45:00] DEBUG [dojo.decorators:76] dojo_async_task <@task: dojo.notifications.helper.send_mail_notification of dojo at 0x7ffffd054560>: running task in the background as user has not set block_execution to True for admin
[29/Oct/2025 17:45:00] ERROR [dojo.api_v2.exception_handler:49] Can't pickle <class 'dojo.models.Tagulous_Finding_tags'>: attribute lookup Tagulous_Finding_tags on dojo.models failed
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/kombu/serialization.py", line 41, in _reraise_errors
    yield
  File "/usr/local/lib/python3.12/site-packages/kombu/serialization.py", line 220, in dumps
    payload = encoder(data)
              ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/kombu/serialization.py", line 347, in pickle_dumps
    return dumper(obj, protocol=pickle_protocol)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_pickle.PicklingError: Can't pickle <class 'dojo.models.Tagulous_Finding_tags'>: attribute lookup Tagulous_Finding_tags on dojo.models failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/rest_framework/views.py", line 512, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/dojo/api_v2/views.py", line 937, in close
    finding_helper.close_finding(
  File "/app/dojo/finding/helper.py", line 822, in close_finding
    create_notification(
  File "/app/dojo/notifications/helper.py", line 81, in create_notification
    notification_manager_class().create_notification(
  File "/app/dojo/notifications/helper.py", line 636, in create_notification
    self._process_notifications(
  File "/app/dojo/notifications/helper.py", line 855, in _process_notifications
    self._get_manager_instance("mail").send_mail_notification(
  File "/app/dojo/decorators.py", line 103, in __wrapper__
    return func.apply_async(args=args, kwargs=kwargs, countdown=countdown)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/celery/app/task.py", line 601, in apply_async
    return app.send_task(
           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/celery/app/base.py", line 930, in send_task
    amqp.send_task_message(P, name, message, **options)
  File "/usr/local/lib/python3.12/site-packages/celery/app/amqp.py", line 523, in send_task_message
    ret = producer.publish(
          ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/kombu/messaging.py", line 178, in publish
    body, content_type, content_encoding = self._prepare(
                                           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/kombu/messaging.py", line 280, in _prepare
    body) = dumps(body, serializer=serializer)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/kombu/serialization.py", line 219, in dumps
    with _reraise_errors(EncodeError):
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
    self.gen.throw(value)
  File "/usr/local/lib/python3.12/site-packages/kombu/serialization.py", line 45, in _reraise_errors
    reraise(wrapper, wrapper(exc), sys.exc_info()[2])
  File "/usr/local/lib/python3.12/site-packages/kombu/exceptions.py", line 34, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.12/site-packages/kombu/serialization.py", line 41, in _reraise_errors
    yield
  File "/usr/local/lib/python3.12/site-packages/kombu/serialization.py", line 220, in dumps
    payload = encoder(data)
              ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/kombu/serialization.py", line 347, in pickle_dumps
    return dumper(obj, protocol=pickle_protocol)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
kombu.exceptions.EncodeError: Can't pickle <class 'dojo.models.Tagulous_Finding_tags'>: attribute lookup Tagulous_Finding_tags on dojo.models failed

[sc-11996]

Copy link
Contributor

@mtesauro mtesauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

context={"request": request},
)
if finding_close.is_valid():
# Remove the prefetched tags to avoid issues with delegating to celery
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what kind of issues and where?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the description with the stack trace

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Almost like we would be better of by just having a couple of M2M fields named tags and some helper methods :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ultimately I think it might be better to only send the finding.id to a celery task and let it fetch the latest and greatest data from the db. but for now I understand this move.

@valentijnscholten valentijnscholten added this to the 2.52.0 milestone Oct 30, 2025
context={"request": request},
)
if finding_close.is_valid():
# Remove the prefetched tags to avoid issues with delegating to celery
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ultimately I think it might be better to only send the finding.id to a celery task and let it fetch the latest and greatest data from the db. but for now I understand this move.

@mtesauro mtesauro merged commit 09f7ffb into bugfix Oct 30, 2025
150 checks passed
@Maffooch
Copy link
Contributor Author

Yeah, I agree that it would be ideal to only pass the ID and get the object from the DB in the task. The unfortunate part of the task is that it can accept a product, engagement, test, finding, or note, so it would take quite a restructure to accommodate that model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants