Merge pull request #18169 from davelopez/24.0_fix_invenio_restricted_access_message

[24.0] Fix error message when accessing restricted Zenodo records
This commit is contained in:
Marius van den Beek
2024-05-17 11:48:30 +02:00
committed by GitHub
+4
View File
@@ -15,6 +15,7 @@ from typing_extensions import (
TypedDict,
)
from galaxy.exceptions import AuthenticationRequired
from galaxy.files.sources import (
Entry,
EntryData,
@@ -406,6 +407,9 @@ class InvenioRepositoryInteractor(RDMRepositoryInteractor):
return headers
def _ensure_response_has_expected_status_code(self, response, expected_status_code: int):
if response.status_code == 403:
record_url = response.url.replace("/api", "").replace("/files", "")
raise AuthenticationRequired(f"Please make sure you have the necessary permissions to access: {record_url}")
if response.status_code != expected_status_code:
error_message = self._get_response_error_message(response)
raise Exception(