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

Cannot update determiner relation #4644

Open
xpusostomos opened this issue Mar 13, 2024 · 1 comment
Open

Cannot update determiner relation #4644

xpusostomos opened this issue Mar 13, 2024 · 1 comment
Labels
1 - Bug Incorrect behavior of the product 2 - API Issues that are related to the APIs todo:verify Needs Verification

Comments

@xpusostomos
Copy link

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:

  1. GET a determiner object via the rest interface.
  2. Change the agent value in that result.
  3. call the PUT rest interface to update it.

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:

  • OS: Windows
  • Browser: [e.g. Chrome, Safari]
    Specify 7 Version: | v7.9.3.1
  • Database Name: uat_specify_herb
    Database Version: | 6.8.03
  • Collection name: ANH
    Reported By
    CSIRO
@xpusostomos xpusostomos added the 1 - Bug Incorrect behavior of the product label Mar 13, 2024
@grantfitzsimmons grantfitzsimmons added the 2 - API Issues that are related to the APIs label Mar 25, 2024
@grantfitzsimmons
Copy link
Member

Hi @grantfitzsimmons, one of the devs working on our synchronisation between the Herbarium data in Specify and the Living Collection data in a Postgres found an issue with one of the APIs and I was hoping you could get someone to take a quick look?

Our method for syncing between the two systems is to have the Living Collection database use APIs to update/add the data when needed in Specify, but there seems to be a problem specifically with the Determiner table API. All the details were added to a GH ticket: Cannot update determiner relation · Issue #4644 · specify/specify7 (github.com)

It might be user-error on our side, but if it is a bug this will prevent our go-live of both systems so we'd be keen to get a fix!

Reported by: CSIRO on Asana

@emenslin emenslin added the todo:verify Needs Verification label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - Bug Incorrect behavior of the product 2 - API Issues that are related to the APIs todo:verify Needs Verification
Projects
None yet
Development

No branches or pull requests

3 participants