Skip to content
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

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

jask1m
Copy link

@jask1m jask1m commented Jul 20, 2024

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.

Copy link
Contributor

@evanugarte evanugarte left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this

Comment on lines +140 to +144
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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants