DMPonline’s current OpenAIRE implementation catches some 404-style failures but does not have much structured handling for timeouts, malformed JSON, provider outages, or disabled providers.
This PR improves this by returning statuses such as :blank, :invalid, and :not_found, and by rescuing SocketError, HTTParty::Error, Timeout::Error, and JSON::ParserError.
However, there are two remaining concerns.
First, provider failures still appear to collapse into “not found” if neither provider returns metadata. This means a provider outage, timeout, malformed response, or disabled provider can be presented to the user as:
“Could not find metadata for the provided DOI.”
This is misleading, because the DOI may exist and the provider may simply be unavailable.
Second, ResearchOutputsController#new silently ignores prefill failures. In the PR, the new action does a DOI lookup if prefill_doi is present:
result = ExternalApis::DoiResolutionService.fetch_metadata(doi: params[:prefill_doi])
return unless result[:status] == :ok && result[:metadata].present?
If this lookup fails, the method simply returns from the prefill logic and renders the normal blank form. The user is not told that prefill failed and the browser may already have shown the DOI lookup as successful before redirecting to the new form.
Suggestions:
- In app/services/external_apis/doi_resolution_service.rb , with changes reflected in app/controllers/research_outputs_controller.rb
- Distinguish :not_found from :service_unavailable or :provider_error
- Return 404 only when providers actually say the DOI was not found.
- Return 503 or a retry-friendly message when providers timeout or fail.
- Ideally avoid the second lookup entirely and prefill from cached metadata generated by the first lookup. (refer to sub-issue DOI metadata is looked up twice #3621 for more details)
DMPonline’s current OpenAIRE implementation catches some 404-style failures but does not have much structured handling for timeouts, malformed JSON, provider outages, or disabled providers.
This PR improves this by returning statuses such as :blank, :invalid, and :not_found, and by rescuing SocketError, HTTParty::Error, Timeout::Error, and JSON::ParserError.
However, there are two remaining concerns.
First, provider failures still appear to collapse into “not found” if neither provider returns metadata. This means a provider outage, timeout, malformed response, or disabled provider can be presented to the user as:
“Could not find metadata for the provided DOI.”
This is misleading, because the DOI may exist and the provider may simply be unavailable.
Second, ResearchOutputsController#new silently ignores prefill failures. In the PR, the new action does a DOI lookup if prefill_doi is present:
If this lookup fails, the method simply returns from the prefill logic and renders the normal blank form. The user is not told that prefill failed and the browser may already have shown the DOI lookup as successful before redirecting to the new form.
Suggestions: