Skip to content

Adding Exception handling for MilvusClient V2 #1671

Merged
sre-ci-robot merged 6 commits intomilvus-io:masterfrom
divyaruhil:v2_exception
Nov 13, 2025
Merged

Adding Exception handling for MilvusClient V2 #1671
sre-ci-robot merged 6 commits intomilvus-io:masterfrom
divyaruhil:v2_exception

Conversation

@divyaruhil
Copy link
Copy Markdown
Contributor

@divyaruhil divyaruhil commented Nov 10, 2025

Currently, milvus-java-sdk returns generic DEADLINE_EXCEEDED error for all connection-related issues (invalid host, wrong port, or certificate errors).
This makes it difficult to identify the root cause .
DEADLINE_EXCEEDED: CallOptions deadline exceeded after 7.780172042s. Name resolution delay 2.199438000 seconds. [closed=[], open=[[wait_for_ready, buffered_nanos=7788263209, waiting_for_connection]]]

As per our discussion, there’s no direct way to unwrap specific exceptions for MilvusClientV2.

This PR introduces enhanced exception handling to validate and provide clearer error messages for invalid hostname, port, and certificate issues in MilvusClientV2.

Fix for issue

@sre-ci-robot
Copy link
Copy Markdown

Welcome @divyaruhil! It looks like this is your first PR to milvus-io/milvus-sdk-java 🎉

@yhmo
Copy link
Copy Markdown
Contributor

yhmo commented Nov 10, 2025

@divyaruhil
Thank you for your pr. I have one concern: it might break some users' online business if the pre-check methods can not handle all cases. Can we add a flag to the ConnectConfig to enable/disable the pre-check process? I would prefer to set its default value to "false".

public class ConnectConfig {
  private boolean enablePrecheck = false;  // default value is false
  ......
}

public class MilvusClientV2 {
    private void connect(ConnectConfig connectConfig) {
        this.connectConfig = connectConfig;
        if (connectConfig.isEnablePrecheck()) {
            validateHostname(connectConfig);
            validatePort(connectConfig);
            validateCert(connectConfig);
        }
        ......

@divyaruhil
Copy link
Copy Markdown
Contributor Author

Hi @yhmo , thankyou for reviewing, i have made the required changes.

@yhmo
Copy link
Copy Markdown
Contributor

yhmo commented Nov 10, 2025

Hi @divyaruhil
Still have 5 comments about the error code and timeout values.

@divyaruhil
Copy link
Copy Markdown
Contributor Author

divyaruhil commented Nov 10, 2025

Hi @yhmo , can u pls point me out what error code and timeout values you are referring to ? I am only able to see one review comment which is this one #1671 (comment).

@yhmo
Copy link
Copy Markdown
Contributor

yhmo commented Nov 10, 2025

You can switch to the "Files changed" page, the comments are in the right panel:
Screenshot from 2025-11-10 19-17-17
Screenshot from 2025-11-10 19-17-48
Screenshot from 2025-11-10 19-18-08
Screenshot from 2025-11-10 19-18-28
Screenshot from 2025-11-10 19-18-42

@divyaruhil
Copy link
Copy Markdown
Contributor Author

divyaruhil commented Nov 11, 2025

Hi @yhmo,

Thanks for sharing the screenshot! It seems there might be a small glitch — I’m unable to view your review comments on my side.
Screenshot 2025-11-11 at 11 17 03 AM
@yhmo
I have a doubt from one of your review comments regarding whether socket.connect() can handle a proxy address. I’m not entirely clear on that part. Can you please help me understand the proxy address part ?
Other than that i have addressed other review comments.

@mergify mergify Bot removed the ci-passed label Nov 11, 2025
Divya added 5 commits November 11, 2025 00:39
…ilvusClientV2

Signed-off-by: Divya <DIVYA2@ibm.com>
Signed-off-by: Divya <DIVYA2@ibm.com>
Signed-off-by: Divya <DIVYA2@ibm.com>
Signed-off-by: Divya <DIVYA2@ibm.com>
Signed-off-by: Divya <DIVYA2@ibm.com>
@yhmo
Copy link
Copy Markdown
Contributor

yhmo commented Nov 12, 2025

Hi @yhmo,

Thanks for sharing the screenshot! It seems there might be a small glitch — I’m unable to view your review comments on my side. Screenshot 2025-11-11 at 11 17 03 AM @yhmo I have a doubt from one of your review comments regarding whether socket.connect() can handle a proxy address. I’m not entirely clear on that part. Can you please help me understand the proxy address part ? Other than that i have addressed other review comments.

The ConnectConfig class has a member named "proxyAddress", user can assign a proxy address as a string. The proxyAddress is passed into the ManagedChannelBuilder by the configureProxy() method, when user wants to connect the milvus server via a proxy server.

public ProxiedSocketAddress proxyFor(SocketAddress targetServerAddress) {

When user has a proxy server, the connection between the client and milvus server might be unreachable.

@divyaruhil
Copy link
Copy Markdown
Contributor Author

divyaruhil commented Nov 12, 2025

Thanks @yhmo for the clarification. I wanted to share that I've actually tested the current implementation with proxyAddress configurations, and it's working correctly with all the validation methods.

As per my knowledge , Proxy configuration is managed at the HTTP/gRPC client layer, not at the individual socket connection level.

When a proxy is configured, the actual TCP connection establishes with the proxy server, which then forwards traffic to the final destination .

My current validation methods (validateHostname, validatePort, validateCert) are specifically designed to verify the final Milvus server destination.

Signed-off-by: Divya <DIVYA2@ibm.com>
@yhmo
Copy link
Copy Markdown
Contributor

yhmo commented Nov 13, 2025

Thanks @yhmo for the clarification. I wanted to share that I've actually tested the current implementation with proxyAddress configurations, and it's working correctly with all the validation methods.

As per my knowledge , Proxy configuration is managed at the HTTP/gRPC client layer, not at the individual socket connection level.

When a proxy is configured, the actual TCP connection establishes with the proxy server, which then forwards traffic to the final destination .

My current validation methods (validateHostname, validatePort, validateCert) are specifically designed to verify the final Milvus server destination.

Ok, sounds good. I will merge this pr into the source code and cherry-pick it to the 2.6 branch. Thank you!

@yhmo
Copy link
Copy Markdown
Contributor

yhmo commented Nov 13, 2025

/lgtm
/approve

@sre-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: divyaruhil, yhmo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sre-ci-robot sre-ci-robot merged commit 50958be into milvus-io:master Nov 13, 2025
5 checks passed
yhmo pushed a commit to yhmo/milvus-sdk-java that referenced this pull request Nov 13, 2025
* Adding Exception handling for validating hostname, port and cert in  MilvusClientV2

Signed-off-by: Divya <DIVYA2@ibm.com>

* Addressing review comments

Signed-off-by: Divya <DIVYA2@ibm.com>

* formatting correction

Signed-off-by: Divya <DIVYA2@ibm.com>

* Addressing review comments

Signed-off-by: Divya <DIVYA2@ibm.com>

* fixing compilation error

Signed-off-by: Divya <DIVYA2@ibm.com>

* Corrected validateCert implementation

Signed-off-by: Divya <DIVYA2@ibm.com>

---------

Signed-off-by: Divya <DIVYA2@ibm.com>
Co-authored-by: Divya <DIVYA2@ibm.com>
sre-ci-robot pushed a commit that referenced this pull request Nov 13, 2025
* Adding Exception handling for validating hostname, port and cert in  MilvusClientV2



* Addressing review comments



* formatting correction



* Addressing review comments



* fixing compilation error



* Corrected validateCert implementation



---------

Signed-off-by: Divya <DIVYA2@ibm.com>
Co-authored-by: Divya <117009486+divyaruhil@users.noreply.github.com>
Co-authored-by: Divya <DIVYA2@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants