-
Notifications
You must be signed in to change notification settings - Fork 983
[KYUUBI-7316] Fix parsePropertyFromUrl to remove query string from parsed values #7317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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
parsePropertyFromUrlto 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) { |
Copilot
AI
Jan 29, 2026
There was a problem hiding this comment.
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.
| if (queryIndex > 0) { | |
| if (queryIndex >= 0) { |
| 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('?'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kyuubi/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java
Lines 482 to 514 in dfd9b49
| /** | |
| * 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; | |
| } |
There was a problem hiding this comment.
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
Why are the changes needed?
Fixed the
parsePropertyFromUrlmethod inUtils.javato properly remove query string parts (everything after ?) from parsed JDBC URL property values, making it consistent with theextractURLComponentsmethod.When parsing JDBC URLs with query strings like:
jdbc:hive2://host:10012/db;auth=JWT?kyuubi.session.cluster=clusterA.The
parsePropertyFromUrlmethod was incorrectly returningJWT?kyuubi.session.cluster=clusterAfor theauthproperty, whileextractURLComponentscorrectly returned onlyJWT. This inconsistency could cause authentication failures in JWT auth scenarios with additional query parameters.How was this patch tested?
Was this patch authored or co-authored using generative AI tooling?
No.