Skip to content

Conversation

mkleene
Copy link
Contributor

@mkleene mkleene commented Sep 22, 2025

No description provided.

@mkleene mkleene requested review from a team as code owners September 22, 2025 13:57
Copy link
Contributor

Summary of Changes

Hello @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 AddressNormalizer failed to properly process network addresses provided without a scheme, such as direct IP addresses or hostnames. The core change involves enhancing the URI parsing mechanism to be more resilient, allowing the system to correctly infer and apply appropriate schemes (http/https) and default ports to these malformed inputs. This ensures consistent and reliable address normalization across various input formats.

Highlights

  • Improved URI Parsing: The AddressNormalizer now correctly handles URLs provided as raw IP addresses or hostnames without an explicit scheme (e.g., 192.168.1.1:400), which previously caused parsing errors.
  • New Helper Method for Robust Parsing: A private static helper method, getInitialUri, has been introduced to encapsulate the URI parsing logic. This method attempts to parse the URI directly and, if it fails due to a missing scheme, retries by prepending a 'fake://' scheme to allow the URI class to correctly identify the host and port.
  • Expanded Test Coverage: New test cases have been added to AddressNormalizerTest to specifically validate the correct normalization of IP addresses, both with and without specified ports, for both secure (HTTPS) and insecure (HTTP) connections.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@mkleene
Copy link
Contributor Author

mkleene commented Sep 22, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@mkleene mkleene changed the title fix: we can't post things like 192.168.1.1:400 fix: we can't parse things like 192.168.1.1:400 Sep 23, 2025
@mkleene mkleene changed the title fix: we can't parse things like 192.168.1.1:400 fix: we can't parse things like 192.168.1.1:4000 Sep 23, 2025
Copy link

sonarqubecloud bot commented Oct 8, 2025

@mkleene mkleene merged commit dc3142d into main Oct 9, 2025
12 checks passed
@mkleene mkleene deleted the fix-bad-hostname-parsing branch October 9, 2025 14:04
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