PyMISP icon indicating copy to clipboard operation
PyMISP copied to clipboard

I use add_attribute but i have a error in this func.

Open yilmazdincer opened this issue 2 years ago • 3 comments

line 779, in add_attribute if ('errors' in new_attribute and new_attribute['errors'][0] == 403 KeyError: 0

yilmazdincer avatar May 02 '23 07:05 yilmazdincer

I add attributes in multiple using add_attribute (I give a list to value) and I get the error I show above. I show the reason for this below.

Something went wrong (403): {'saved': False, 'name': 'Could not add Attribute', 'message': 'Could not add Attribute', 'url': '/attributes/add', 'errors': {'attribute_0': {'value': ['A similar attribute already exists for this event.']}, 'attribute_1': {'value': ['A similar attribute already exists for this event.']}, 'attribute_2': {'value': ['A similar attribute already exists for this event.']}, 'attribute_3': {'value': ['A similar attribute already exists for this event.']}}}

yilmazdincer avatar May 02 '23 08:05 yilmazdincer

Do you have duplicate attributes in your list? If so, you might want to check out this on https://www.misp-project.org/2023/04/13/MISP.2.4.170.released.html/ which was requested in https://github.com/MISP/MISP/issues/5257

Fixes

  • Add support for a breakOnDuplicate named parameter on /attributes/add endpoint, default value is true which keeps the current behavior of throwing an error when the user tries to add duplicate attribute to an event. When set to false the endpoint will work as an upsert, updating the attributes timestamp and any other properties provided in the payload, no error logs will be written.

github-germ avatar May 02 '23 12:05 github-germ

TY!

yilmazdincer avatar May 03 '23 11:05 yilmazdincer