Skip to content

DatalinkRecordMixin's record.getdataset() falls back to access_url #776

Description

@stvoutsin

Description

DatalinkRecordMixin.getdataset() catches any failure in the DataLink path and falls back to the base Record.getdataset():

pyvo/pyvo/dal/adhoc.py

Lines 435 to 447 in a7c6e6c

@stream_decode_content
def getdataset(self, timeout=None):
try:
url = next(self.getdatalink().bysemantics('#this')).access_url
response = self._session.get(url, stream=True, timeout=timeout)
try:
response.raise_for_status()
except requests.RequestException as ex:
raise DALServiceError.from_except(ex, url)
return response.raw
except (DALServiceError, ValueError, StopIteration):
# this should go to Record.getdataset()
return super().getdataset(timeout=timeout)

The fallback fetches the record's access.reference column without checking the access_format, which may cause confusion for services that follow the Datalink-indirection model where access_url points at a DataLink links endpoint insstead of the data product directly.
So in this scenario, if the first request fails the fallback will fetch the links endpoint and return the VOTable as the dataset, and the user doesn't get any error messages they could otherwise use to discover what went wrong.

Also, note that this path reads .access_url directly instead of getdataurl() which will make error rows lead to a misleading error.

I think we need to fix this by:

  • Skip the fallback when the record's access_format indicates a DataLink document
  • Propagate the error_message from a DataLink error row instead of swallowing it?

If this seems reasonable and I'm not missing something I'm happy to put in a PR

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions