Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@wangyum
Copy link
Member

@wangyum wangyum commented Jan 29, 2026

Why are the changes needed?

Fixed the parsePropertyFromUrl method in Utils.java to properly remove query string parts (everything after ?) from parsed JDBC URL property values, making it consistent with the extractURLComponents method.

When parsing JDBC URLs with query strings like: jdbc:hive2://host:10012/db;auth=JWT?kyuubi.session.cluster=clusterA.
The parsePropertyFromUrl method was incorrectly returning JWT?kyuubi.session.cluster=clusterA for the auth property, while extractURLComponents correctly returned only JWT. This inconsistency could cause authentication failures in JWT auth scenarios with additional query parameters.

How was this patch tested?

  1. URLs with query strings parse properties correctly without the query string
  2. URLs without query strings continue to work as expected
  3. Both parsing methods return consistent results

Was this patch authored or co-authored using generative AI tooling?

No.

@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (dfd9b49) to head (e89260c).

Files with missing lines Patch % Lines
...c/main/java/org/apache/kyuubi/jdbc/hive/Utils.java 0.00% 5 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##           master   #7317   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files         698     698           
  Lines       43654   43658    +4     
  Branches     5896    5897    +1     
======================================
- Misses      43654   43658    +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@turboFei turboFei requested a review from Copilot January 29, 2026 17:06
Copy link

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 fixes an inconsistency in JDBC URL property parsing where parsePropertyFromUrl was incorrectly including query string parameters in property values while extractURLComponents correctly excluded them. This could cause authentication failures when using JWT auth with additional query parameters.

Changes:

  • Modified parsePropertyFromUrl to strip query string portions (everything after ?) from parsed property values
  • Added comprehensive test coverage for both query string and non-query string scenarios
  • Ensured both parsing methods return consistent results

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java Updated parsePropertyFromUrl to remove query string parameters from property values
kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/UtilsTest.java Added tests verifying consistency between parsing methods and correct handling of query strings

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

String value = token.trim().substring((key.trim() + "=").length());
// Remove query string part (anything after ?) to match extractURLComponents behavior
int queryIndex = value.indexOf('?');
if (queryIndex > 0) {
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The condition queryIndex > 0 will fail to handle query strings at the start of the value (e.g., ?param=value). Change the condition to queryIndex >= 0 to correctly handle all cases where a query string is present, including when it appears at position 0.

Suggested change
if (queryIndex > 0) {
if (queryIndex >= 0) {

Copilot uses AI. Check for mistakes.
return token.trim().substring((key.trim() + "=").length());
String value = token.trim().substring((key.trim() + "=").length());
// Remove query string part (anything after ?) to match extractURLComponents behavior
int queryIndex = value.indexOf('?');
Copy link
Member

Choose a reason for hiding this comment

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

/**
* Get the authority string from the supplied uri, which could potentially contain multiple
* host:port pairs.
*/
private static String getAuthorityFromJdbcURL(String uri) throws JdbcUriParseException {
String authorities;
/*
* For a jdbc uri like:
* jdbc:hive2://<host1>:<port1>,<host2>:<port2>/dbName;sess_var_list?conf_list#var_list Extract
* the uri host:port list starting after "jdbc:hive2://", till the 1st "/" or "?" or "#"
* whichever comes first & in the given order Examples:
* jdbc:hive2://host1:port1,host2:port2,host3:port3/db;k1=v1?k2=v2#k3=v3
* jdbc:hive2://host1:port1,host2:port2,host3:port3/;k1=v1?k2=v2#k3=v3
* jdbc:hive2://host1:port1,host2:port2,host3:port3?k2=v2#k3=v3
* jdbc:hive2://host1:port1,host2:port2,host3:port3#k3=v3
*/
String matchedUrlPrefix = getMatchedUrlPrefix(uri);
int fromIndex = matchedUrlPrefix.length();
int toIndex = -1;
ArrayList<String> toIndexChars = new ArrayList<>(Arrays.asList("/", "?", "#"));
for (String toIndexChar : toIndexChars) {
toIndex = uri.indexOf(toIndexChar, fromIndex);
if (toIndex > 0) {
break;
}
}
if (toIndex < 0) {
authorities = uri.substring(fromIndex);
} else {
authorities = uri.substring(fromIndex, toIndex);
}
return authorities;
}

Copy link
Member

Choose a reason for hiding this comment

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

see https://kyuubi.readthedocs.io/en/master/client/jdbc/kyuubi_jdbc.html#basic-connection-url-format

jdbc:subprotocol://host:port[/catalog]/[schema];<clientProperties;><[#|?]sessionProperties>

We can parse the clientProperties only to get auth property

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