-
Notifications
You must be signed in to change notification settings - Fork 2
fix: we can't parse things like 192.168.1.1:4000
#294
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 @mkleene, 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 an issue where the 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 fixes a bug that prevented parsing of schemeless URIs with IP addresses, such as 192.168.1.1:400
. The fix introduces a new helper method, getInitialUri
, which cleverly retries parsing by prepending a temporary scheme if the initial attempt fails. This is a good approach and is well-supported by the new test cases. I have one suggestion to enhance the error reporting in the new helper method to ensure that the most relevant exception details are preserved, which will aid in debugging potential parsing issues in the future.
try { | ||
return new URI(format("fake://%s", urlString)); | ||
} catch (URISyntaxException e) { | ||
throw new SDKException("error parsing url [" + urlString + "]", initialThrown); |
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.
In the case of a second URISyntaxException
, the exception e
is discarded, and initialThrown
is used as the cause for the SDKException
. However, the second exception e
might contain more specific details about why the URL is malformed, especially after we've attempted to fix a missing scheme. For instance, with an input like 1.2.3.4:badport
, initialThrown
would indicate an invalid scheme, while e
would point to the invalid port number, which is the more precise error.
To improve diagnostics, it would be beneficial to preserve both exceptions. You can achieve this by adding e
as a suppressed exception to initialThrown
.
initialThrown.addSuppressed(e);
throw new SDKException("error parsing url [" + urlString + "]", initialThrown);
/gemini review |
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 fixes an issue where URLs consisting of an IP address and port could not be parsed correctly. This is achieved by introducing a new getInitialUri
method that attempts to parse the URL, and if that fails, retries by prepending a fake scheme. This is a good approach to handle scheme-less URIs. The changes are well-tested with new test cases for IP-based addresses. I have one suggestion to refactor the new getInitialUri
method for better readability and to fix a minor typo in a comment.
|
192.168.1.1:400
192.168.1.1:400
192.168.1.1:400
192.168.1.1:4000
No description provided.