-
Notifications
You must be signed in to change notification settings - Fork 1
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
20240719 improve delete api #46
base: dev
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.
lets do the logic like this, logger.exception will include the error automatically
try:
with MetricsHandler.query_time.labels("delete").time():
if sqlite_helpers.delete_url(DATABASE_FILE, alias):
try: # URL deleted, now attempt the associated data
qr_code_cache.delete(alias)
cache.delete(alias)
except Exception:
logging.exception(f"Error deleting alias {alias} from cache") # log failure without raising exception
return {"message": "URL deleted successfully"}
raise HTTPException(status_code=HttpResponse.NOT_FOUND.code)
except Exception:
logging.exception(f"Unexpected error in delete_url for {alias}")
raise HTTPException(status_code=HttpResponse.INTERNAL_SERVER_ERROR.code)
cleezy
Outdated
@@ -0,0 +1 @@ | |||
/Users/jasonkim/Desktop/SCE/SCE-CLI/cleezy |
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.
delete this
try: # URL deleted, now attempt the associated data | ||
qr_code_cache.delete(alias) | ||
cache.delete(alias) | ||
except Exception: | ||
logging.exception(f"Error deleting alias {alias} from cache") # log failure without raising exception |
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.
we can do the nested try for now, and watch the logs to see what happens
when the /delete endpoint was called, the url is deleted, but then trying to delete the associated data (qrcode) returns an error, which in turn confuses the frontend and disrupted the ui from being re-rendered. rewrote the api to handle errors such that it won't raise exceptions, but logs whatever failed. - might need to look into how to handle deletion of associated data later if it keeps occurring.