[Bug] parsePropertyFromUrl returns incorrect value when JDBC URL contains query parameters
- Dominant language
- Scala
- Stars
- 2.4k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
### Search before asking
- [x] I have searched in the [issues](https://github.com/apache/kyuubi/issues?q=is%3Aissue) 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:
```bash
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
```logtalk
```
### Kyuubi Engine Log Output
```logtalk
```
### Kyuubi Server Configurations
```yaml
```
### Kyuubi Engine Configurations
```yaml
```
### Additional context
_No response_
### Are you willing to submit PR?
- [x] 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.
Contributor guide
Research direction
Start in Utils.java around lines 567-575 and compare parsePropertyFromUrl() with extractURLComponents() for the JDBC URL shown in the issue. Reproduce the beeline URL case and verify that parsing auth returns only JWT, matching the session variable extracted by extractURLComponents().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100