Skip to content

Commit 7df8c5d

Browse files
authored
Merge pull request #880 from hubmapconsortium/karlburke/AppHeaderValidationBug
Fire drill fix for entity-level validator call
2 parents 4d88a81 + 8300e0e commit 7df8c5d

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/app.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4017,8 +4017,12 @@ def multiple_components():
40174017
validate_token_if_auth_header_exists(request)
40184018
# Get user token from Authorization header
40194019
user_token = get_user_token(request)
4020+
# Create a dictionary as required to use an entity validator. Ignore the
4021+
# options_dict['existing_entity_dict'] support for PUT requests, since this
4022+
# @app.route() only supports POST.
4023+
options_dict = {'http_request': request}
40204024
try:
4021-
schema_validators.validate_application_header_before_entity_create("Dataset", request)
4025+
schema_validators.validate_application_header_before_entity_create(options_dict=options_dict)
40224026
except Exception as e:
40234027
bad_request_error(str(e))
40244028
require_json(request)

src/schema/schema_validators.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
2525
Parameters
2626
----------
27-
normalized_type : str
28-
One of the types defined in the schema yaml: Dataset, Upload
29-
request: Flask request
30-
The instance of Flask request passed in from application request
27+
options_dict : dict
28+
A dictionary of data needed by this entity-level validator based upon the create/POST or
29+
update/PUT actions. The dictionary will always have 'http_request' and will have
30+
'existing_entity_dict' for a PUT request.
3131
"""
3232
def validate_application_header_before_entity_create(options_dict):
3333
if 'http_request' in options_dict:
@@ -52,10 +52,10 @@ def validate_application_header_before_entity_create(options_dict):
5252
5353
Parameters
5454
----------
55-
normalized_type : str
56-
One of the types defined in the schema yaml: Dataset, Upload
57-
request: Flask request
58-
The instance of Flask request passed in from application request
55+
options_dict : dict
56+
A dictionary of data needed by this entity-level validator based upon the create/POST or
57+
update/PUT actions. The dictionary will always have 'http_request' and will have
58+
'existing_entity_dict' for a PUT request.
5959
"""
6060
def validate_entity_not_locked_before_update(options_dict):
6161
if 'existing_entity_dict' in options_dict:

0 commit comments

Comments
 (0)