Skip to content

[Bug] parsePropertyFromUrl returns incorrect value when JDBC URL contains query parameters #7316

@wangyum

Description

@wangyum

Code of Conduct

Search before asking

  • I have searched in the issues and found no similar issues.

Describe the bug

Description

The Utils.parsePropertyFromUrl() method incorrectly includes query string parameters in the returned value when parsing JDBC URLs. This causes inconsistent behavior compared to Utils.extractURLComponents() and leads to
authentication failures in beeline.

Problem

For a JDBC URL like:
jdbc:hive2://host:10012/db;auth=JWT?kyuubi.session.cluster=hermes

  • parsePropertyFromUrl(url, "auth") returns: "JWT?kyuubi.session.cluster=clusterA"
  • extractURLComponents(url, props).getSessionVars().get("auth") returns: "JWT"

These two methods should return the same value, but they don't.

Impact

This bug causes HTTP 401 authentication failures when using beeline with JWT authentication:

bin/beeline -u "jdbc:hive2://host:10012/db;transportMode=http;httpPath=cliservice;ssl=true;auth=JWT?kyuubi.session.cluster=clusterA"     

Error:

org.apache.kyuubi.shaded.thrift.transport.TTransportException: HTTP Response code: 401                                                                                                                                                  

The bug affects any code path that uses parsePropertyFromUrl() to extract authentication parameters from JDBC URLs with query strings.

Root Cause

The parsePropertyFromUrl() method (Utils.java:567-575) splits by semicolons but doesn't handle the ? query string delimiter:

public static String parsePropertyFromUrl(final String url, final String key) {                                                                                                                                                         
  String[] tokens = url.split(";");                                                                                                                                                                                                     
  for (String token : tokens) {                                                                                                                                                                                                         
    if (token.trim().startsWith(key.trim() + "=")) {                                                                                                                                                                                    
      return token.trim().substring((key.trim() + "=").length());  // ❌ Returns "JWT?kyuubi.session.cluster=clusterA"                                                                                                                    
    }                                                                                                                                                                                                                                   
  }                                                                                                                                                                                                                                     
  return null;                                                                                                                                                                                                                          
}                                                                                                                                                                                                                                       

Meanwhile, extractURLComponents() correctly uses URI.getPath() which stops at the ? delimiter.

Affects Version(s)

master

Kyuubi Server Log Output

Kyuubi Engine Log Output

Kyuubi Server Configurations

Kyuubi Engine Configurations

Additional context

No response

Are you willing to submit PR?

  • Yes. I would be willing to submit a PR with guidance from the Kyuubi community to fix.
  • No. I cannot submit a PR at this time.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions