-
Notifications
You must be signed in to change notification settings - Fork 19
fix: remove redundant error logging in exception handling #68
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @jiazhangx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the SDK's exception handling mechanism by eliminating redundant error logging. Previously, exceptions were logged internally before being re-raised, leading to potential duplication with user-level logs and occasional empty log messages. The change ensures that the SDK focuses on re-throwing exceptions for upstream handling, improving the clarity and efficiency of error reporting without generating unnecessary internal log noise. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request removes redundant error logging from an exception handler in dashscope/api_entities/http_request.py, which is a good practice for an SDK as it leaves logging decisions to the application developer. The change is correct and aligns with the goal described.
While the change is correct, it's incomplete. The same pattern of logging an error and then re-raising it exists in other places. For consistency and to fully resolve the issue, I recommend applying the same fix to:
- The
_handle_aio_requestmethod in the same file (dashscope/api_entities/http_request.pyat lines 163-168). - The
_handle_requestmethod indashscope/api_entities/aiohttp_request.py(at lines 237-242).
Additionally, during this refactoring, it would be a good opportunity to review the use of except BaseException and consider changing it to except Exception to avoid catching system-exiting exceptions like KeyboardInterrupt, which is a common best practice in Python.
|
Thank you for your pull request. We added logging when exceptions occur in the SDK to provide clearer error information and prevent users from missing critical details in cases where they haven't added their own logging—otherwise, relevant error logs might be absent entirely. Additionally, we noticed your observation about the logged messages appearing empty, which could indeed indicate an issue. Could you please help by providing a way to reproduce this behavior, or even better, submit a direct fix? Thank you! |
We strongly recommend adjusting the logging level of all error logs in the SDK to warning. This approach offers two key benefits:
|
The current code logs exceptions with
logger.error(e)before rethrowing them viaraise e, which has issues:logging should be handled by users themselves.
logger.error(e)may print empty logs.It is recommended to remove these logs or lower their level to debug.