@@ -142,7 +142,7 @@ def main(req: func.HttpRequest) -> str:
142
142
storage_key = ss [1 ]
143
143
if not storage_account or not storage_key :
144
144
return write_http_response (
145
- 400 ,
145
+ 400 ,
146
146
{ 'message' : 'Function configuration error: NO Azure Storage connection string found!' }
147
147
)
148
148
@@ -159,13 +159,24 @@ def main(req: func.HttpRequest) -> str:
159
159
try :
160
160
req_body = req .get_json ()
161
161
except ValueError :
162
- pass
162
+ # Case: Empty body
163
+ return write_http_response (
164
+ 400 ,
165
+ { 'message' : 'Invalid HTTP request body' }
166
+ )
163
167
else :
168
+ # Case: Exception raised in get_json()
169
+ if not 'req_body' in locals ():
170
+ return write_http_response (
171
+ 400 ,
172
+ { 'message' : 'Invalid HTTP request body' }
173
+ )
174
+ # Case: Invalid parameters
164
175
if not req_body .get ('permission' ) or not req_body .get ('container' ):
165
176
return write_http_response (
166
177
400 ,
167
178
{ 'message' : 'Permission and container parameters must be included in HTTP request body' }
168
- )
179
+ )
169
180
170
181
permission = req_body .get ('permission' )
171
182
container_name = req_body .get ('container' )
@@ -175,9 +186,9 @@ def main(req: func.HttpRequest) -> str:
175
186
token_ttl = int (req_body .get ('ttl' ))
176
187
if token_ttl < 1 :
177
188
return write_http_response (
178
- 400 ,
189
+ 400 ,
179
190
{ 'message' : 'Token ttl must be digit and more than 0' }
180
- )
191
+ )
181
192
182
193
# Generate SAS Token
183
194
token_dict = generate_sas_token (
0 commit comments