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

The /repositories/:repo_id/classification_terms/:id/parent endpoint returns a 500 error #1384

Closed
AustinTSchaffer opened this issue Oct 19, 2018 · 3 comments · Fixed by #1867
Assignees
Labels

Comments

@AustinTSchaffer
Copy link
Contributor

I'm trying to use the /repositories/:repo_id/classification_terms/:id/parent endpoint of the API to reorder some classification terms. It seems like every POST to this endpoint triggers a 500 error, with the text:

{
	"error": "super: no superclass method `update_position_only' for #<ClassificationTerm:0x326de5dc>\nDid you mean?  update_only"
}

image

It looks like the update_position_only method attempts to call the update_position_only method of the super-class, which does not contain an update_position_only method.

Stack Trace

Endpoint.post('/repositories/:repo_id/classification_terms/:id/parent')

obj.update_position_only(params[:parent], params[:position])

def update_position_only(parent_id, position)

Environment

{
	"databaseProductName": "MySQL",
	"databaseProductVersion": "5.7.23",
	"ruby_version": "2.3.0",
	"host_os": "linux",
	"host_cpu": "x86_64",
	"build": "java1.7",
	"archivesSpaceVersion": "v2.5.0"
}

Although, I don't think the version matters, because the git-blame says that the method has remained unchanged since it was added 6 years ago.

@smoore4moma
Copy link
Contributor

I was getting a different, but similar, 500 error that no longer happened after upgrading to v2.5.2 (and rebuilding indexes).

@AustinTSchaffer
Copy link
Contributor Author

@smoore4moma I just retried my steps and I am still getting this same issue, using v2.5.2. Looking at the code on the master branch, it appears that the ClassificationTerm model's update_position_only still references super, when the method does not exist on the superclass.

https://github.com/archivesspace/archivesspace/blob/master/backend/app/model/classification_term.rb

Using a python client for ArchivesSpace:

import aspace
client = aspace.client.ASpaceClient('http://localhost/test_aspace/api')
client.authenticate()
### <Response [200]>
client.get('/')
### <Response [200]>
client.get('/').json()
### {'databaseProductName': 'MySQL', 'build': 'java1.7', 'ruby_version': '2.3.0', 'databaseProductVersion': '5.7.25', 'host_os': 'linux', 'archivesSpaceVersion': 'master', 'host_cpu': 'x86_64'}
client.get('/repositories/2/classification_terms/1')
### <Response [200]>
client.get('/repositories/2/classification_terms/1').json()
### {'repository': {'ref': '/repositories/2'}, 'display_string': 'Classification Term 2', 'user_mtime': '2019-05-08T17:21:07Z', 'system_mtime': '2019-05-08T17:21:07Z', 'title': 'Classification Term 2', 'lock_version': 0, 'identifier': '2', 'uri': '/repositories/2/classification_terms/1
### ', 'position': 0, 'created_by': 'admin', 'path_from_root': [{'identifier': 'Test', 'title': 'Test'}, {'identifier': '2', 'title': 'Classification Term 2'}], 'linked_records': [], 'jsonmodel_type': 'classification_term', 'publish': True, 'last_modified_by': 'admin', 'classification'
### : {'ref': '/repositories/2/classifications/1'}, 'create_time': '2019-05-08T17:21:07Z'}
client.get('/repositories/2/classification_terms/2').json()
### {'repository': {'ref': '/repositories/2'}, 'display_string': 'Classification Term 1', 'user_mtime': '2019-05-08T17:21:15Z', 'system_mtime': '2019-05-08T17:21:15Z', 'title': 'Classification Term 1', 'lock_version': 0, 'identifier': '1', 'uri': '/repositories/2/classification_terms/2
### ', 'position': 1, 'created_by': 'admin', 'path_from_root': [{'identifier': 'Test', 'title': 'Test'}, {'identifier': '1', 'title': 'Classification Term 1'}], 'linked_records': [], 'jsonmodel_type': 'classification_term', 'publish': True, 'last_modified_by': 'admin', 'classification'
### : {'ref': '/repositories/2/classifications/1'}, 'create_time': '2019-05-08T17:21:15Z'}
client.post('/repositories/2/classification_terms/1/parent?parent=0&position=0').json()
### {'error': "super: no superclass method `update_position_only' for #<ClassificationTerm:0x5d7b3e2f>\nDid you mean?  update_only"}
client.post('/repositories/2/classification_terms/1/parent?parent=0&position=1').json()
### {'error': "super: no superclass method `update_position_only' for #<ClassificationTerm:0x36952f42>\nDid you mean?  update_only"}
client.post('/repositories/2/classification_terms/1/parent?parent=1&position=1').json()
### {'error': "super: no superclass method `update_position_only' for #<ClassificationTerm:0x567a0505>\nDid you mean?  update_only"}
client.post('/repositories/2/classification_terms/1/parent?parent=2&position=1').json()
### {'error': "super: no superclass method `update_position_only' for #<ClassificationTerm:0x654bb276>\nDid you mean?  update_only"}
client.post('/repositories/2/classification_terms/1/parent?position=1').json()
### {'error': "super: no superclass method `update_position_only' for #<ClassificationTerm:0x5fa40cb9>\nDid you mean?  update_only"}
client.post('/repositories/2/classification_terms/1/parent?position=2').json()
### {'error': "super: no superclass method `update_position_only' for #<ClassificationTerm:0x41a6d2d2>\nDid you mean?  update_only"}
client.post('/repositories/2/classification_terms/1/parent?position=0').json()
### {'error': "super: no superclass method `update_position_only' for #<ClassificationTerm:0x1e0cadba>\nDid you mean?  update_only"}
client.post('/repositories/2/classification_terms/1/parent?parent=0').json()
### {'error': "super: no superclass method `update_position_only' for #<ClassificationTerm:0x2cb7d18b>\nDid you mean?  update_only"}
client.post('/repositories/2/classification_terms/1/parent?parent=1').json()
### {'error': "super: no superclass method `update_position_only' for #<ClassificationTerm:0x5cc69f2c>\nDid you mean?  update_only"}
client.post('/repositories/2/classification_terms/1/parent?parent=2').json()
### {'error': "super: no superclass method `update_position_only' for #<ClassificationTerm:0x1e1416e7>\nDid you mean?  update_only"}
### 

Could you post screenshots of this endpoint working in your environment?

@smoore4moma
Copy link
Contributor

Sorry. Wish I could help, but we actually do not have any classification terms defined and I only have prod to query. And we are on Windows. Just FYI.

/repositories/2/classification_terms/0
{"error":"ClassificationTerm not found"}
/
{ "databaseProductName": "MySQL", "databaseProductVersion": "5.6.24-log", "ruby_version": "2.3.0", "host_os": "mswin32", "host_cpu": "x86_64", "build": "java1.7", "archivesSpaceVersion": "v2.5.2" }

lorawoodford added a commit to lorawoodford/archivesspace that referenced this issue Apr 16, 2020
@lorawoodford lorawoodford self-assigned this Apr 16, 2020
mark-cooper added a commit that referenced this issue May 19, 2020
Issue #1384: Use correct method for classification_terms/parent endpoint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants