Skip to content

fix: IPv6 host support#4367

Open
hrishikesh-nalawade wants to merge 35 commits into
v3.x.xfrom
hrishikesh-nalawade/GH4318/IPv6-host-formatting
Open

fix: IPv6 host support#4367
hrishikesh-nalawade wants to merge 35 commits into
v3.x.xfrom
hrishikesh-nalawade/GH4318/IPv6-host-formatting

Conversation

@hrishikesh-nalawade
Copy link
Copy Markdown
Member

Description

Code changes to support IPv6 address

Linked to #4318

Type of change

Please delete options that are not relevant.

  • fix: Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • PR title conforms to commit message guideline ## Commit Message Structure Guideline
  • I have commented my code, particularly in hard-to-understand areas. In JS I did provide JSDoc
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The java tests in the area I was working on leverage @nested annotations
  • Any dependent changes have been merged and published in downstream modules

Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements IPv6 host support across the APIML codebase by replacing manual URL string formatting with a centralized utility class to properly handle IPv6 addresses. IPv6 addresses require square brackets in URLs to be RFC-compliant.

  • Added UrlUtils utility class with methods to format IPv6 addresses correctly
  • Updated URL construction throughout the codebase to use the new utility methods
  • Added proper IPv6 address handling in route definitions and service registrations

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
common-service-core/src/main/java/org/zowe/apiml/util/UrlUtils.java New utility class with IPv6-aware URL formatting methods
zaas-service/src/main/java/org/zowe/apiml/zaas/cache/CachingServiceClient.java Replaced manual URL formatting with UrlUtils.getUrl()
security-service-client-spring/src/main/java/org/zowe/apiml/security/client/service/GatewaySecurityService.java Updated login, query, and OIDC validation endpoints to use UrlUtils
gateway-service/src/main/java/org/zowe/apiml/gateway/services/ServicesInfoService.java Updated base URL construction for service info
gateway-service/src/main/java/org/zowe/apiml/gateway/service/routing/RouteDefinitionProducer.java Added comprehensive IPv6 handling for route definitions and external URLs
gateway-service/src/main/java/org/zowe/apiml/gateway/service/GatewayIndexService.java Updated WebClient base URL construction
gateway-service/src/main/java/org/zowe/apiml/gateway/filters/ZaasSchemeTransformRest.java Added hostname formatting for ZAAS requests
gateway-service/src/main/java/org/zowe/apiml/gateway/config/RegistryConfig.java Updated gateway service address configuration for IPv6
gateway-service/src/main/java/org/zowe/apiml/gateway/caching/CachingServiceClientRest.java Updated caching service URL construction
api-catalog-services/src/main/java/org/zowe/apiml/apicatalog/swagger/api/ApiDocV3Service.java Updated OpenAPI server URL formatting
api-catalog-services/src/main/java/org/zowe/apiml/apicatalog/swagger/ApiDocRetrievalServiceLocal.java Updated SpringDoc server URL construction

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread common-service-core/src/main/java/org/zowe/apiml/util/UrlUtils.java Outdated
@hrishikesh-nalawade hrishikesh-nalawade changed the title IPv6 host support fix: IPv6 host support Oct 29, 2025
@EvaJavornicka EvaJavornicka moved this from New to In Progress in API Mediation Layer Backlog Management Oct 29, 2025
openAPI.getServers()
.forEach(server -> server.setUrl(
String.format("%s://%s/%s", scheme, getHostname(), server.getUrl())));
UrlUtils.getUrl(scheme, UrlUtils.formatHostnameForUrl(getHostname())) + "/" + server.getUrl()));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

getHostname() returns host+port, which contains ":" even if there is no IPv6 address. This will probably create an incorrect URL

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've considered the possibility that getHostname() might be returning the host along with the port, and I've added handling for that here. But, I suspect the issue might be related to the formatHostnameForUrl() method. I'll take a closer look to better understand what's going wrong.

}

// Check if this is an IPv6 address (contains multiple colons)
if (hostname.contains(":") && !hostname.startsWith("[")) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is it safe to assume that any address containing ":" is IPv6? Isn't there a better validation?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, that’s a valid point. I also feel that relying solely on ":" for validation might not be sufficient. I’ll explore better alternatives and see what could work more reliably.

hrishikesh-nalawade and others added 4 commits November 5, 2025 17:08
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
…host-formatting' into hrishikesh-nalawade/GH4318/IPv6-host-formatting
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
hrishikesh-nalawade and others added 5 commits November 7, 2025 16:14
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
…host-formatting' into hrishikesh-nalawade/GH4318/IPv6-host-formatting
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
hrishikesh-nalawade and others added 11 commits November 17, 2025 16:07
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
…host-formatting' into hrishikesh-nalawade/GH4318/IPv6-host-formatting
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
35.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
35.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
@pull-request-size pull-request-size Bot added size/XL and removed size/L labels Feb 5, 2026
hrishikesh-nalawade and others added 4 commits February 17, 2026 17:11
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
Signed-off-by: hrishikesh-nalawade <hrishikesh.nalawade.17@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
52.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@github-actions
Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions Bot added the stale label May 19, 2026
@hrishikesh-nalawade hrishikesh-nalawade self-assigned this May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Sensitive Sensitive change that requires peer review size/XL stale

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants