Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook inconsistency - on_created_tag not triggered for reuploaded objects #1015

Open
1 of 4 tasks
psrok1 opened this issue Jan 9, 2025 · 0 comments
Open
1 of 4 tasks
Labels
type:bug Something isn't working zone:backend MWDB backend core related tasks

Comments

@psrok1
Copy link
Member

psrok1 commented Jan 9, 2025

Environment information

  • MWDB version (from /about): v2.14.0
  • Installation method:
    • mwdb.cert.pl service
    • From PyPi (pip install mwdb-core)
    • From docker-compose
    • Other (please explain)
  • Plugins installed:

Behaviour the bug (what happened?)

on_created_tag is triggered during object upload only if object is new. If object upload was requested along with some new tags but object already exists, on_created_tag is not triggered for these new tags that are appended to the object.

Expected behaviour

on_created_tag should be triggered every time tag is added to the object.

Actually supported hook list is pretty broad but they're triggered only in oddly specific cases e.g. on_created_attribute is triggered only in attribute was added by calling POST /api/{type}/{hash}/attribute.

Current implementation is based on direct calls of hook dispatchers inside endpoint handling methods. I think better implementation would be a list of actions collected in e.g. g.request_actions. Every time we add tag using mwdb.model.object.Object.add_tag, proper actions are added to the queue.

Finally, actions are iterated using dedicated hook dispatcher method, where proper hooks are called depending on the action. Hook dispatcher method should be called at the end of the request handling, after transaction was committed. Failed hook call should not result in ISE 500 although proper error should be logged (non-fatal errors handling is also a problem there: #891)

@psrok1 psrok1 added type:bug Something isn't working zone:backend MWDB backend core related tasks labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working zone:backend MWDB backend core related tasks
Projects
None yet
Development

No branches or pull requests

1 participant