Skip to content

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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions