Skip to content

Commit b6932f7

Browse files
authored
Merge pull request #814 from hubmapconsortium/yuanzhou/file-upload-fix
Fix missing request header handling
2 parents 68c6502 + b92eab8 commit b6932f7

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/schema/schema_triggers.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,8 +1287,12 @@ def commit_thumbnail_file(property_key, normalized_type, user_token, existing_da
12871287

12881288
logger.info(f"Commit the uploaded thumbnail file of tmp file id {tmp_file_id} for entity {entity_uuid} via ingest-api call...")
12891289

1290+
request_headers = {
1291+
'Authorization': f'Bearer {user_token}'
1292+
}
1293+
12901294
# Disable ssl certificate verification
1291-
response = requests.post(url = ingest_api_target_url, headers = schema_manager._create_request_headers(user_token), json = json_to_post, verify = False)
1295+
response = requests.post(url = ingest_api_target_url, headers = request_headers, json = json_to_post, verify = False)
12921296

12931297
if response.status_code != 200:
12941298
msg = f"Failed to commit the thumbnail file of tmp file id {tmp_file_id} via ingest-api for entity uuid: {entity_uuid}"
@@ -1387,8 +1391,12 @@ def delete_thumbnail_file(property_key, normalized_type, user_token, existing_da
13871391

13881392
logger.info(f"Remove the uploaded thumbnail file {file_uuid} for entity {entity_uuid} via ingest-api call...")
13891393

1394+
request_headers = {
1395+
'Authorization': f'Bearer {user_token}'
1396+
}
1397+
13901398
# Disable ssl certificate verification
1391-
response = requests.post(url = ingest_api_target_url, headers = schema_manager._create_request_headers(user_token), json = json_to_post, verify = False)
1399+
response = requests.post(url = ingest_api_target_url, headers = request_headers, json = json_to_post, verify = False)
13921400

13931401
# response.json() returns an empty array because
13941402
# there's no thumbnail file left once the only one gets removed
@@ -1457,10 +1465,12 @@ def sync_component_dataset_status(property_key, normalized_type, user_token, exi
14571465
creation_action = schema_neo4j_queries.get_entity_creation_action_activity(schema_manager.get_neo4j_driver_instance(), child_uuid)
14581466
if creation_action == 'Multi-Assay Split':
14591467
url = schema_manager.get_entity_api_url() + SchemaConstants.ENTITY_API_UPDATE_ENDPOINT + '/' + child_uuid
1460-
header = schema_manager._create_request_headers(user_token)
1468+
request_headers = {
1469+
'Authorization': f'Bearer {user_token}'
1470+
}
14611471
header[SchemaConstants.HUBMAP_APP_HEADER] = SchemaConstants.INGEST_API_APP
14621472
header[SchemaConstants.INTERNAL_TRIGGER] = SchemaConstants.COMPONENT_DATASET
1463-
response = requests.put(url=url, headers=header, json=status_body)
1473+
response = requests.put(url=url, headers=request_headers, json=status_body)
14641474

14651475

14661476
####################################################################################################
@@ -2082,8 +2092,12 @@ def _commit_files(target_property_key, property_key, normalized_type, user_token
20822092

20832093
logger.info(f"Commit the uploaded file of temp_file_id {temp_file_id} for entity {entity_uuid} via ingest-api call...")
20842094

2095+
request_headers = {
2096+
'Authorization': f'Bearer {user_token}'
2097+
}
2098+
20852099
# Disable ssl certificate verification
2086-
response = requests.post(url = ingest_api_target_url, headers = schema_manager._create_request_headers(user_token), json = json_to_post, verify = False)
2100+
response = requests.post(url = ingest_api_target_url, headers = request_headers, json = json_to_post, verify = False)
20872101

20882102
if response.status_code != 200:
20892103
msg = f"Failed to commit the file of temp_file_id {temp_file_id} via ingest-api for entity uuid: {entity_uuid}"
@@ -2188,9 +2202,13 @@ def _delete_files(target_property_key, property_key, normalized_type, user_token
21882202
}
21892203

21902204
logger.info(f"Remove the uploaded files for entity {entity_uuid} via ingest-api call...")
2205+
2206+
request_headers = {
2207+
'Authorization': f'Bearer {user_token}'
2208+
}
21912209

21922210
# Disable ssl certificate verification
2193-
response = requests.post(url = ingest_api_target_url, headers = schema_manager._create_request_headers(user_token), json = json_to_post, verify = False)
2211+
response = requests.post(url = ingest_api_target_url, headers = request_headers, json = json_to_post, verify = False)
21942212

21952213
if response.status_code != 200:
21962214
msg = f"Failed to remove the files via ingest-api for entity uuid: {entity_uuid}"

0 commit comments

Comments
 (0)