Skip to content

Java SDK naming registration should reject blank or invalid instance IPย #15305

Closed

Description

@KomachiSion

Issue Description

When registering a naming instance through the public Java SDK, the SDK/gRPC path does not currently reject a blank instance IP with a controlled NacosException.

The HTTP OpenAPI path validates InstanceForm.ip as a required field and returns a parameter error for blank IP. However, the Java SDK registration path calls NamingUtils.checkInstanceIsLegal(instance), and that helper currently checks null instance, heartbeat metadata, and cluster-name format, but does not validate blank or malformed IP. The gRPC InstanceRequestHandler then passes the Instance to clientOperationService.registerInstance(...) without an equivalent required-IP validation.

Expected Behavior

Java SDK naming registration should reject blank or invalid instance IPs predictably, preferably with NacosException.INVALID_PARAM, and should align with the HTTP API validation contract where possible.

Actual Behavior

A Java SDK IT attempt using an Instance whose IP is blank did not receive the expected controlled parameter exception on the standalone SDK/gRPC path, so the scenario cannot be asserted as a stable IT contract yet.

Suggested Fix

Confirm the intended Java SDK contract, then add required-IP and malformed-IP validation either in the SDK-side instance validation or the server-side gRPC request validation path. After the behavior is fixed, add Java SDK IT coverage for blank and invalid IP registration failures.

Related Context

This was found while improving Java SDK integration-test scenario coverage under test/java-sdk-test. The invalid-IP IT scenario is intentionally documented as a gap until the contract is fixed.

Activity

  1. added this to the 3.2.3 milestone on Jun 4, 2026
  2. added a commit that references this issue on Jun 4, 2026
  3. daguimu commented on Jun 5, 2026

    @daguimu
    Contributor

    Hi, I'd like to work on this. Quick summary to confirm the direction first:

    The HTTP API already rejects a blank instance IP (InstanceForm.validate()), but the Java SDK path (NamingUtils.checkInstanceIsLegal, used by NacosNamingService.registerInstance) doesn't check the IP at all โ€” so a blank IP isn't rejected with a proper INVALID_PARAM.

    I'd add a blank-IP check in NamingUtils.checkInstanceIsLegal to match the HTTP contract. I'd only check for blank (not IP format), since hostnames are valid and the HTTP side doesn't enforce a format either. Sound good? If so I'll send a PR with a regression test.

  4. KomachiSion commented on Jun 5, 2026

    @KomachiSion
    CollaboratorAuthor

    Thanks,

    If check in NamingUtils.checkInstanceIsLegal is ok.

    And more consider to check in InstanceRequestHandler, to avoid other programer language also leak the checks.

  5. added a commit that references this issue on Jun 7, 2026
  6. added a commit that references this issue on Jun 16, 2026
  7. added a commit that references this issue on Jul 1, 2026
  8. added a commit that references this issue on Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/ClientRelated to Nacos Client SDKarea/Namingkind/bugCategory issues or prs related to bug.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions