Skip to content

DatasetFileDocument.get_presigned_url silently returns None when response lacks presignedUrl #4725

@Yicong-Huang

Description

@Yicong-Huang

What happened?

amber/src/main/python/pytexera/storage/dataset_file_document.py::DatasetFileDocument.get_presigned_url does response.json().get("presignedUrl"), so a 200 response that omits the presignedUrl field silently returns None instead of raising. read_file then calls requests.get(None) and the caller gets a less-actionable error than the explicit-status path.

How to reproduce?

import os
from unittest.mock import patch, MagicMock
from pytexera.storage.dataset_file_document import DatasetFileDocument

os.environ["USER_JWT_TOKEN"] = "t"
os.environ["FILE_SERVICE_GET_PRESIGNED_URL_ENDPOINT"] = "http://x"

doc = DatasetFileDocument("/o/d/v/f.csv")
with patch("pytexera.storage.dataset_file_document.requests.get") as g:
    g.return_value = MagicMock(status_code=200, **{"json.return_value": {}, "text": "{}"})
    print(doc.get_presigned_url())  # prints None instead of raising

Version

1.1.0-incubating (Pre-release/Master)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions