Cannot update determiner relation #4644
Labels
1 - Bug
Incorrect behavior of the product
2 - API
Issues that are related to the APIs
todo:verify
Needs Verification
The determiner table basically has a link to a determination and a link to an agent. If I modify the agent and call the update rest interface, I get the error:
Determiner must have unique agent in determination
To Reproduce
Steps to reproduce the behavior:
here is an example of what I PUT and what I get back...
PUT au.gov.environment.livingcollection.SpecifyService URL: https://herbuat.specify.csiro.au/api/specify/determiner/357212/
ERROR au.gov.environment.livingcollection.SpecifyService Request Body: {"id":357212,"determination":"/api/specify/determination/357212/","agent":"/api/specify/agent/107/","version":7}
ERROR au.gov.environment.livingcollection.SpecifyService Response Body: {"exception": "BusinessRuleException", "message": "Determiner must have unique agent in determination", "data": "{'table': 'Determiner', 'localizationKey': 'childFieldNotUnique', 'fieldName': 'agent', 'fieldData': {'agent': 'Agent object (107)'}, 'parentField': 'determination', 'parentData': {'determination': 'Determination object (357212)'}, 'conflicting': [162627]}", "traceback": "Traceback (most recent call last):\n File "/opt/specify7/ve/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\n File "/opt/specify7/specifyweb/specify/views.py", line 36, in wrapped\n return view(request, *args, **kwargs)\n File "/opt/specify7/ve/lib/python3.8/site-packages/django/views/decorators/cache.py", line 31, in _cache_controlled\n response = viewfunc(request, *args, **kw)\n File "/opt/specify7/specifyweb/specify/views.py", line 72, in view\n return dispatch_func(request, *args, **kwargs)\n File "/opt/specify7/specifyweb/specify/api.py", line 133, in resource_dispatch\n obj = put_resource(request.specify_collection,\n File "/usr/lib/python3.8/contextlib.py", line 75, in inner\n return func(*args, **kwds)\n File "/opt/specify7/specifyweb/specify/api.py", line 613, in put_resource\n return update_obj(collection, agent, name, id, version, data)\n File "/opt/specify7/specifyweb/specify/api.py", line 636, in update_obj\n obj.save(force_update=True)\n File "/opt/specify7/specifyweb/specify/build_models.py", line 63, in save\n return super(model, self).save(*args, **kwargs)\n File "/opt/specify7/ve/lib/python3.8/site-packages/django/db/models/base.py", line 739, in save\n self.save_base(using=using, force_insert=force_insert,\n File "/opt/specify7/ve/lib/python3.8/site-packages/django/db/models/base.py", line 763, in save_base\n pre_save.send(\n File "/opt/specify7/ve/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 180, in send\n return [\n File "/opt/specify7/ve/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 181, in \n (receiver, receiver(signal=self, sender=sender, **named))\n File "/opt/specify7/specifyweb/businessrules/orm_signal_handler.py", line 29, in handler\n rule(sender, kwargs['instance'])\n File "/opt/specify7/specifyweb/businessrules/uniqueness_rules.py", line 110, in check_unique\n raise get_exception(conflicts, matchable, field_map)\nspecifyweb.businessrules.exceptions.BusinessRuleException: ('Determiner must have unique agent in determination', {'table': 'Determiner', 'localizationKey': 'childFieldNotUnique', 'fieldName': 'agent', 'fieldData': {'agent': 'Agent object (107)'}, 'parentField': 'determination', 'parentData': {'determination': 'Determination object (357212)'}, 'conflicting': [162627]})\n"}
This determination has only one existing determiner, so there should be no question of the agent being unique. I've tried many examples of this and always get the same result.
Expected behavior
Seems no reason i shouldn't be able to update the agent in a determiner object. In any case, the error message is wrong.
Alternatively, please fill out the following information manually:
Specify 7 Version: | v7.9.3.1
Database Version: | 6.8.03
Reported By
CSIRO
The text was updated successfully, but these errors were encountered: