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

Update relationship is failing half of the time #7328

Open
pkernevez opened this issue Jan 12, 2023 · 0 comments
Open

Update relationship is failing half of the time #7328

pkernevez opened this issue Jan 12, 2023 · 0 comments
Assignees

Comments

@pkernevez
Copy link

pkernevez commented Jan 12, 2023

CKAN version

2.9.7

Describe the bug

When updating a relationship between 2 dataset the first call fails with a 500 error, resending the same request succeeds.
First call response:

{
    "help": "http://localhost:5001/api/3/action/help_show?name=package_relationship_update",
    "error": {
        "__type": "Internal Server Error",
        "message": "Internal Server Error"
    },
    "success": false
}

Response of the Same request just after:
{
"help": "http://localhost:5001/api/3/action/help_show?name=package_relationship_update",
"success": true,
"result": {
"subject": "Proxy Recall",
"type": "derives_from",
"object": "Governance Ratings",
"comment": "Test comment"
}
}

Steps to reproduce

  1. Create a link between 2 dataset
  2. Update the same link with a change in the comment
  3. The first time it fails
  4. Redo the same request, it succeeds

Expected behaviour

Having the first request on success

Additional details

Trace on server:

ckan  | Traceback (most recent call last):
ckan  |   File "/srv/app/src/ckan/ckan/config/middleware/../../views/api.py", line 293, in action
ckan  |     result = function(context, request_data)
ckan  |   File "/srv/app/src/ckan/ckan/logic/__init__.py", line 504, in wrapped
ckan  |     result = _action(context, data_dict, **kw)
ckan  |   File "/srv/app/src/ckan/ckan/logic/action/update.py", line 642, in package_relationship_update
ckan  |     return _update_package_relationship(entity, comment, context)
ckan  |   File "/srv/app/src/ckan/ckan/logic/action/update.py", line 586, in _update_package_relationship
ckan  |     rel_dict = relationship.as_dict(package=relationship.subject,
ckan  |   File "/usr/lib/python3.8/site-packages/sqlalchemy/orm/attributes.py", line 282, in __get__
ckan  |     return self.impl.get(instance_state(instance), dict_)
ckan  |   File "/usr/lib/python3.8/site-packages/sqlalchemy/orm/attributes.py", line 699, in get
ckan  |     value = self.callable_(state, passive)
ckan  |   File "/usr/lib/python3.8/site-packages/sqlalchemy/orm/strategies.py", line 683, in _load_for_state
ckan  |     raise orm_exc.DetachedInstanceError(
ckan  | sqlalchemy.orm.exc.DetachedInstanceError: Parent instance <PackageRelationship at 0x7f207ec4d220> is not bound to a Session; lazy load operation of attribute 'subject' cannot proceed (Background on this error at: http://sqlalche.me/e/bhk3)
pkernevez pushed a commit to pkernevez/ckanext-relationshipdisplay that referenced this issue Jan 12, 2023
pkernevez pushed a commit to pkernevez/ckanext-relationshipdisplay that referenced this issue Jan 12, 2023
pkernevez pushed a commit to pkernevez/ckanext-relationshipdisplay that referenced this issue Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants