Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def validate_request(request: Request, request_type: AnyStr) -> Dict:
if not request.body_exists:
raise WebError(code=400, detail='BAD_REQUEST')
try:
request_json = await request.json(loads=ujson_loads)
except ValueError:
raise WebError(code=400, detail='BAD_REQUEST')
if not request_json.get('taskID'):
raise WebError(code=422, detail='taskID')
if request_type == 'publish':
request_json = await _validate_publish_request(request_json)
elif request_type == 'excel':
request_json = await _validate_excel_request(request_json)
request_json['language'] = request.headers.get('Accept-Language')
return request_json