fix(model): Fix NPE when OpenAIClient stream call handle error#800
fix(model): Fix NPE when OpenAIClient stream call handle error#800aihai wants to merge 4 commits intoagentscope-ai:mainfrom
Conversation
Summary of ChangesHello @aihai, 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 resolves a potential NullPointerException that could occur in the Highlights
Changelog
Activity
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.
Code Review
This pull request addresses a potential NullPointerException during stream error handling in the OpenAIClient. The fix involves changing the statusCode parameter in OpenAIException.create to an Integer to allow for null values, and providing a default status code of 418 when it is null. Additionally, a new test case has been added to improve test coverage for error handling in stream calls. The changes are logical and effectively resolve the issue.
| int statusCode, String message, String errorCode, String responseBody) { | ||
| Integer statusCode, String message, String errorCode, String responseBody) { | ||
| if (null == statusCode) { | ||
| statusCode = 418; |
There was a problem hiding this comment.
Using the HTTP status code 418 ("I'm a teapot") as a default is a bit unusual and can be confusing for developers who are not familiar with this context. To improve readability and maintainability, it would be better to define this as a named constant, for example private static final int DEFAULT_STATUS_CODE_WHEN_NULL = 418;, and add a comment explaining its purpose as a placeholder for when no status code is available. Since adding a constant might be outside the scope of this change, at a minimum, a code comment explaining the choice of 418 would be beneficial.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
AgentScope-Java Version
1.0.10
Description
Fixes: #786
Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)