Skip to content

Better error message and sanity check for signed URL generation. #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions terra_notebook_utils/drs.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ def access(drs_url: str,
key=info.key,
sa_credentials=info.credentials,
requester_pays_user_project=billing_project)
# one last sanity check
response = requests.get(url, headers={'Range': 'bytes=0-1'})

if response.status_code >= 400:
raise DRSResolutionError(f'Could not generate a valid signed URL for {drs_url} . Make sure you have access '
f'to this file. If you believe you have access, relinking your account projects in '
f'your Terra profile may solve this issue (even if it shows your linking is currently '
f'valid). Otherwise, if you believe you have access and have relinked, please '
f'contact Terra support.')

return url.strip()

def _get_drs_gs_creds(response: dict) -> Optional[dict]:
Expand Down