-
Notifications
You must be signed in to change notification settings - Fork 43
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
Logging, Exception Management Assignment #30
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not approved, many changes to be made.
@@ -15,6 +15,7 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
info logs missing throughout the file
@@ -12,4 +12,6 @@ | |||
|
|||
|
|||
def get_enriched_lead_json(adf_json: dict) -> dict: | |||
if adf_json == {}: | |||
logging.warning("Empty JSON") | |||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise KeyError for missing 'adf' key and check if adj_json is valid to raise ValueError
fast_api_als/routers/three_pl.py
Outdated
@@ -17,10 +17,16 @@ async def reset_authkey(request: Request, token: str = Depends(get_token)): | |||
body = json.loads(body) | |||
provider, role = get_user_role(token) | |||
if role != "ADMIN" and (role != "3PL"): | |||
logging.info("Role is neither Admin nor 3PL") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise http exception with proper status code, add info logs where necessary
@@ -47,6 +48,7 @@ async def submit(file: Request, apikey: APIKey = Depends(get_api_key)): | |||
|
|||
# check if xml was not parsable, if not return | |||
if not obj: | |||
logging.error("XML could not be parsed") | |||
provider = db_helper_session.get_api_key_author(apikey) | |||
obj = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try except for line 59
@@ -95,11 +99,13 @@ async def submit(file: Request, apikey: APIKey = Depends(get_api_key)): | |||
for future in as_completed(futures): | |||
result = future.result() | |||
if result.get('Duplicate_Api_Call', {}).get('status', False): | |||
logging.warning("Duplicate API call") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log info for the time taken for request completion
@@ -199,6 +211,7 @@ async def submit(file: Request, apikey: APIKey = Depends(get_api_key)): | |||
res = sqs_helper_session.send_message(message) | |||
|
|||
else: | |||
logging.info("Rejected current response") | |||
message = { | |||
'put_file': { | |||
'item': item, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 226 try except block
# throw proper HTTPException | ||
pass | ||
logging.error("Lead conversion not updated") | ||
raise HTTPException(status_code = 406, detail = "Lead conversion not updated") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*already updated, status_code should be 400
fast_api_als/database/db_helper.py
Outdated
@@ -355,3 +355,9 @@ def verify_response(response_code): | |||
|
|||
session = get_boto3_session() | |||
db_helper_session = DBHelper(session) | |||
|
|||
|
|||
def log_res_data(obj : DBHelper): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this function called?
Kindly check the current changes and suggest any if needed |
logging.info("Role is neither Admin nor 3PL") | ||
pass | ||
logging.error("Role required to be admin or 3PL") | ||
raise HTTPException(status_code = 400, detail = "Role required to be admin or 3PL") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
400 status code is for a Bad request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decide whether this should be 401 or 403.
This is Done |
No description provided.