datacite / lupo

DataCite REST API
https://api.datacite.org
MIT License
12 stars 8 forks source link

Unable to retrieve single Activity records via the REST API #1060

Closed codycooperross closed 11 months ago

codycooperross commented 12 months ago

Describe the bug

It should be possible to retrieve single Activity records via the REST API based on the id listed in the activities endpoints for a given Activity. However, attempting to retrieve an activity using its id at /activities/[id] returns a 404.

Expected Behaviour

Retrieving an Activity based on its id in the REST API returns an individual Activity record.

Current Behaviour

Retrieving an Activity based on its id in the REST API returns a 404.

Steps to Reproduce

Retrieve a list of activities at the /activities endpoint or another relevant endpoint like /dois/[doi]/activities. Attempt to retrieve a single activity using its id in the REST API at /activities/[id].

Context (Environment)

Screenshots

Further details

Proposal

Hypothesis

Possible Implementation

digitaldogsbody commented 12 months ago

I think this is probably because the id exposed by the serializer is not actually the id field: https://github.com/datacite/lupo/blob/master/app/serializers/activity_serializer.rb#L7

The controller uses a slightly weird pattern in that it calls a separate function to get the Activity record before processing the show route: https://github.com/datacite/lupo/blob/master/app/controllers/activities_controller.rb#L6 and https://github.com/datacite/lupo/blob/master/app/controllers/activities_controller.rb#L147-L151. I don't know if there is a reason for this vs what I would consider to be the standard pattern of the show controller doing the lookup (c.f. https://github.com/datacite/lupo/blob/master/app/controllers/datacite_dois_controller.rb#L435-L448)

I suspect if you used the value from the actual id field in the DB/ES record, it would probably work.

digitaldogsbody commented 12 months ago

As a side note, /activities appears to be currently broken in test/production :grimacing:

codycooperross commented 12 months ago

I suspect if you used the value from the actual id field in the DB/ES record, it would probably work.

I actually tried this, and I'm not sure it does, but worth investigating further.

As a side note, /activities appears to be currently broken in test/production 😬

We're working on this! See #1054 #1062

svogt0511 commented 11 months ago

Closing. Fixed by https://github.com/datacite/lupo/pull/1063