Skip to content
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

Quick: Prevent null value from being passed as Tapis tracking ID #1499

Merged
merged 2 commits into from
Dec 10, 2024
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
22 changes: 11 additions & 11 deletions designsafe/apps/api/datafiles/operations/tapis_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def listing(client, system, path, offset=0, limit=100, q=None, *args, **kwargs):
path=(path or '/'),
offset=int(offset),
limit=int(limit),
headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id")})
headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id", "")})

try:
# Convert file objects to dicts for serialization.
Expand Down Expand Up @@ -84,7 +84,7 @@ def detail(client, system, path, *args, **kwargs):
"""
Retrieve the uuid for a file by parsing the query string in _links.metadata.href
"""
_listing = client.files.listFiles(systemId=system, path=urllib.parse.quote(path), offset=0, limit=1, headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id")})
_listing = client.files.listFiles(systemId=system, path=urllib.parse.quote(path), offset=0, limit=1, headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id", "")})
f = _listing[0]
listing_res = {
'system': system,
Expand Down Expand Up @@ -227,7 +227,7 @@ def mkdir(client, system, path, dir_name, *args, **kwargs):
'filePath': path,
'recurse': False},
queue='indexing',
headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id")})
headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id", "")})
return {"result": "OK"}


Expand Down Expand Up @@ -262,7 +262,7 @@ def move(client, src_system, src_path, dest_system, dest_path, *args, **kwargs):
path=src_path,
operation="MOVE",
newPath=dest_path_full,
headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id")})
headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id", "")})

move_file_meta_async.delay(src_system, src_path, dest_system, dest_path_full)

Expand Down Expand Up @@ -325,15 +325,15 @@ def copy(client, src_system, src_path, dest_system, dest_path, *args, **kwargs):
path=src_path,
operation="COPY",
newPath=full_dest_path,
headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id")})
headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id", "")})
else:
src_url = f'tapis://{src_system}/{src_path}'
dest_url = f'tapis://{dest_system}/{full_dest_path}'

copy_response = client.files.createTransferTask(elements=[{
'sourceURI': src_url,
'destinationURI': dest_url
}], headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id")})
}], headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id", "")})
copy_result = {
'uuid': copy_response.uuid,
'status': copy_response.status,
Expand Down Expand Up @@ -369,7 +369,7 @@ def copy(client, src_system, src_path, dest_system, dest_path, *args, **kwargs):
def delete(client, system, path, *args, **kwargs):
return client.files.delete(systemId=system,
filePath=urllib.parse.quote(path),
headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id")})
headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id", "")})

def rename(client, system, path, new_name, *args, **kwargs):
"""Renames a file. This is performed under the hood by moving the file to
Expand Down Expand Up @@ -403,7 +403,7 @@ def rename(client, system, path, new_name, *args, **kwargs):
path=path,
operation="MOVE",
newPath=new_path,
headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id")})
headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id", "")})

move_file_meta_async.delay(system, path, system, new_path)

Expand Down Expand Up @@ -448,7 +448,7 @@ def trash(client, system, path, trash_path, *args, **kwargs):
except tapipy.errors.NotFoundError:
mkdir(client, system, trash_root, trash_foldername)

resp = move(client, system, path, system, trash_path, headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id")})
resp = move(client, system, path, system, trash_path, tapis_tracking_id=kwargs.get("tapis_tracking_id", ""))

return resp

Expand Down Expand Up @@ -489,7 +489,7 @@ def upload(client, system, path, uploaded_file, webkit_relative_path=None, *args
response_json = client.files.insert(systemId=system,
path=dest_path,
file=uploaded_file,
headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id")})
headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id", "")})
return {"result": "OK"}
agave_indexer.apply_async(kwargs={'systemId': system,
'filePath': path,
Expand Down Expand Up @@ -549,7 +549,7 @@ def preview(client, system, path, href="", max_uses=3, lifetime=600, *args, **kw
except FileMetaModel.DoesNotExist:
meta = {}

postit_result = client.files.createPostIt(systemId=system, path=path, allowedUses=max_uses, validSeconds=lifetime, headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id")})
postit_result = client.files.createPostIt(systemId=system, path=path, allowedUses=max_uses, validSeconds=lifetime, headers={"X-Tapis-Tracking-ID": kwargs.get("tapis_tracking_id", "")})
url = postit_result.redeemUrl

if file_ext in settings.SUPPORTED_TEXT_PREVIEW_EXTS:
Expand Down