Skip to content

Conversation

@luddaniel
Copy link
Contributor

Hi everyone :)
Our team identified a issue with api/admin/makeDataCount/:persistentId/updateCitationsForDataset?persistentId=$DOI endpoint that could end up in infinite loop if Datacite result is paginated.
There is 2 reasons for this :

  1. Dataverse depends on Datacite json reponse content to got out of a while loop : https://github.com/IQSS/dataverse/blob/develop/src/main/java/edu/harvard/iq/dataverse/api/MakeDataCountApi.java#L172-L201
    if (links.containsKey("next")) { can always be true.

  2. Datacite seems to have an issue with HATEOAS implementation as it always contains a next link even when you are out of page range or on the last page. Standard recommendation is to remove next link or set it to empty or null on last page. I'll report this issue to Datacite.

Ex:
First page : https://api.datacite.org/events?doi=10.12763/SMDGR1&source=crossref&page[size]=1000

"meta": {
    "total": 10276,
    "total-pages": 11,

"links": {
    "self": "https://api.datacite.org/events?doi=10.12763/SMDGR1&source=crossref&page[size]=1000",
    "next": "https://api.datacite.org/events?doi=10.12763%2FSMDGR1&page%5Bnumber%5D=2&page%5Bsize%5D=1000"
  }

Page number 11 : https://api.datacite.org/events?doi=10.12763%2FSMDGR1&page%5Bnumber%5D=11&page%5Bsize%5D=1000
Still displays a next link :

"links": {
    "self": "https://api.datacite.org/events?doi=10.12763%2FSMDGR1&page%5Bnumber%5D=11&page%5Bsize%5D=1000",
    "next": "https://api.datacite.org/events?doi=10.12763%2FSMDGR1&page%5Bnumber%5D=11&page%5Bsize%5D=1000"
  }

This code aims both to work better with Datacite as is and have a default condition max iteration condition to avoid infinite loop.

Note : worst case scenario, a default max page number of 1000 x 1000 items seems enough regarding crossref...

@luddaniel luddaniel changed the title MakeDataCount may end up in infinite loop MDC - updateCitationsForDataset API may end up in infinite loop May 28, 2025
@luddaniel luddaniel marked this pull request as draft May 28, 2025 13:34
@luddaniel
Copy link
Contributor Author

Turned to DRAFT has it may be needed to use Datacite Support > Pagination > Method 2: Cursor

@pdurbin pdurbin moved this to Ready for Triage in IQSS Dataverse Project May 28, 2025
@luddaniel
Copy link
Contributor Author

Closed in favor of an adapted description and clean commits : #11535

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

Successfully merging this pull request may close these issues.

1 participant