Skip to content

Commit 9a10a63

Browse files
committed
Merge branch 'develop' of https://github.com/CenterForOpenScience/osf.io into refactor-notifications
* 'develop' of https://github.com/CenterForOpenScience/osf.io: Bump version no. Add CHANGELOG move CROSSREF_UNAVAILABLE_DELAY to settings.py handle and 5xx status code from crossref handle 500 error from crossref
2 parents b62daac + d13bdbe commit 9a10a63

File tree

7 files changed

+38
-4
lines changed

7 files changed

+38
-4
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
We follow the CalVer (https://calver.org/) versioning scheme: YY.MINOR.MICRO.
44

5+
25.11.1 (2025-07-03)
6+
====================
7+
8+
- Hotfix to handle crossref's anticipated downtime
9+
510
25.11.0 (2025-06-30)
611
====================
712

osf/management/commands/sync_doi_metadata.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
from django.core.management.base import BaseCommand
88
from osf.models import GuidMetadataRecord, Identifier, Registration, Preprint
99
from framework.celery_tasks import app
10+
from website.identifiers.clients.exceptions import CrossRefUnavailableError
11+
from website.settings import CROSSREF_UNAVAILABLE_DELAY
12+
1013

1114
logger = logging.getLogger(__name__)
1215

@@ -21,6 +24,9 @@ def sync_identifier_doi(self, identifier_id):
2124
identifier.referent.request_identifier_update('doi')
2225
identifier.save()
2326
logger.info(f'Doi update for {identifier.value} complete')
27+
except CrossRefUnavailableError as err:
28+
logger.warning(f'CrossRef is unavailable during sync of {identifier.value} DOI. Error: {err.error}')
29+
self.retry(countdown=CROSSREF_UNAVAILABLE_DELAY)
2430
except Exception as err:
2531
logger.warning(f'[{err.__class__.__name__}] Doi update for {identifier.value} failed because of error: {err}')
2632
self.retry()
@@ -75,6 +81,9 @@ def async_request_identifier_update(self, preprint_id):
7581
preprint = Preprint.load(preprint_id)
7682
try:
7783
preprint.request_identifier_update('doi', create=True)
84+
except CrossRefUnavailableError as err:
85+
logger.warning(f'CrossRef is unavailable during DOI update for preprint {preprint._id}. Error: {err.error}')
86+
self.retry(countdown=CROSSREF_UNAVAILABLE_DELAY)
7887
except Exception as err:
7988
logger.warning(f'[{err.__class__.__name__}] Doi creation failed for the preprint with id {preprint._id} because of error: {err}')
8089
self.retry()

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "OSF",
3-
"version": "25.11.0",
3+
"version": "25.11.1",
44
"description": "Facilitating Open Science",
55
"repository": "https://github.com/CenterForOpenScience/osf.io",
66
"author": "Center for Open Science",

website/identifiers/clients/crossref.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import requests
88
from django.db.models import QuerySet
99

10-
from .exceptions import CrossRefRateLimitError
10+
from .exceptions import CrossRefRateLimitError, CrossRefUnavailableError
1111
from framework.auth.utils import impute_names
1212
from website.identifiers.utils import remove_control_characters
1313
from website.identifiers.clients.base import AbstractIdentifierClient
@@ -267,6 +267,9 @@ def create_identifier(self, preprint, category, include_relation=True):
267267
if response.status_code == 429:
268268
raise CrossRefRateLimitError(response.text)
269269

270+
if response.status_code >= 500:
271+
raise CrossRefUnavailableError(response.text)
272+
270273
return {'doi': doi}
271274

272275
raise NotImplementedError()

website/identifiers/clients/exceptions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@ def __init__(self, error):
1616

1717
def __str__(self):
1818
return self.error
19+
20+
21+
class CrossRefUnavailableError(Exception):
22+
23+
def __init__(self, error):
24+
self.error = error
25+
26+
def __str__(self):
27+
return self.error

website/preprints/tasks.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from framework.exceptions import HTTPError
55
from framework.celery_tasks import app as celery_app
66
from framework.postcommit_tasks.handlers import enqueue_postcommit_task, get_task_from_postcommit_queue
7+
from website.identifiers.clients.exceptions import CrossRefUnavailableError
8+
from website.settings import CROSSREF_UNAVAILABLE_DELAY
79

810

911
CROSSREF_FAIL_RETRY_DELAY = 12 * 60 * 60
@@ -68,6 +70,7 @@ def update_or_enqueue_on_preprint_updated(preprint_id, saved_fields=None):
6870
@celery_app.task(bind=True, acks_late=True, max_retries=5, default_retry_delay=CROSSREF_FAIL_RETRY_DELAY)
6971
def mint_doi_on_crossref_fail(self, preprint_id):
7072
from osf.models import Preprint
73+
7174
preprint = Preprint.load(preprint_id)
7275
vg = preprint.versioned_guids.first()
7376
existing_versions_without_minted_doi = Preprint.objects.filter(
@@ -84,5 +87,9 @@ def mint_doi_on_crossref_fail(self, preprint_id):
8487
self.retry()
8588
else:
8689
crossref_client = preprint.get_doi_client()
87-
if crossref_client:
88-
crossref_client.create_identifier(preprint, category='doi', include_relation=False)
90+
try:
91+
if crossref_client:
92+
crossref_client.create_identifier(preprint, category='doi', include_relation=False)
93+
except CrossRefUnavailableError as err:
94+
logger.warning(f'CrossRef is unavailable during minting DOI on fail for preprint {preprint_id}. Error: {err.error}')
95+
self.retry(countdown=CROSSREF_UNAVAILABLE_DELAY)

website/settings/defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ def parent_dir(path):
342342
CROSSREF_PASSWORD = None
343343
CROSSREF_URL = None # Location to POST crossref data. In production, change this to the production CrossRef API endpoint
344344
CROSSREF_DEPOSITOR_EMAIL = 'None' # This email will receive confirmation/error messages from CrossRef on submission
345+
CROSSREF_UNAVAILABLE_DELAY = 24 * 60 * 60
345346

346347
ECSARXIV_CROSSREF_USERNAME = None
347348
ECSARXIV_CROSSREF_PASSWORD = None

0 commit comments

Comments
 (0)