Repository navigation
Add UserAgent for connector service calls - #1175
Merged
Merged
Conversation
Problem: The custom user agent from 'useragententry' parameter was not included in the connector service feature flags request. This happened because UserAgentManager.setUserAgent() was setting the custom user agent AFTER triggering the client type determination (which fetches feature flags). Root Cause: In UserAgentManager.setUserAgent(): - Line 28 called getClientUserAgent() which triggered getClientType() - getClientType() called DatabricksDriverFeatureFlagsContextFactory.getInstance() - Feature flags were fetched WITHOUT the custom user agent - Custom user agent was set afterwards (too late) Solution: Reordered UserAgentManager.setUserAgent() to set custom user agent BEFORE calling getClientUserAgent(): 1. Set base product 2. Set custom user agent FIRST via UserAgent.withOtherInfo() 3. THEN call getClientUserAgent() which triggers feature flags fetch Result: Custom user agent is now included in ALL HTTP requests including the connector service request. Testing: - Added testCustomUserAgentIncludedBeforeClientTypeEvaluation() test - Updated existing tests to be version-agnostic - All UserAgentManagerTest tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Added buildUserAgentForConnectorService() to build separate UA for connector service - Modified DatabricksDriverFeatureFlagsContext to use new method for feature flag requests - Maintains proper order for backend requests: base -> client type -> custom - Custom UA now included in both connector service and backend requests without circular dependency - Updated test to verify proper order: client type before custom user agent
- Added DEBUG log when SEA circuit breaker is open - Shows time remaining until circuit closes - Helps users understand THRIFT fallback due to 429 rate limits
- Created parseCustomerUserAgent() helper method - Eliminates code duplication in setUserAgent() and buildUserAgentForConnectorService() - Added try-catch protection for UserAgent.sanitize() calls - All tests pass (7/7)
jprakash-db
approved these changes
Jan 12, 2026
jprakash-db
left a comment
Collaborator
There was a problem hiding this comment.
Overall LGTM. Some minor comments
| // Set custom User-Agent for connector service (includes custom user agent without client | ||
| // type) | ||
| String userAgent = | ||
| com.databricks.jdbc.common.util.UserAgentManager.buildUserAgentForConnectorService( |
Collaborator
There was a problem hiding this comment.
I think we can directly import the function and then use
import com.databricks.jdbc.common.util.UserAgentManager.buildUserAgentForConnectorService
Then use - buildUserAgentForConnectorService
| return new String[] {customerName, customerVersion}; | ||
| } catch (Exception e) { | ||
| LOGGER.debug("Failed to parse customer userAgent entry {}, Error {}", customerUserAgent, e); | ||
| return null; |
Collaborator
There was a problem hiding this comment.
Instead of null, can we give a generic name. So we can later using telemetry identity how many requests are coming from incorrect User Agent arguments
Collaborator
Author
There was a problem hiding this comment.
We read from other signals in those scenario. This is a private function, and null is used to denote that value is not provided by customer or partner
| if (parsed != null) { | ||
| try { | ||
| userAgent.append(" ").append(parsed[0]).append("/").append(UserAgent.sanitize(parsed[1])); | ||
| } catch (Exception e) { |
Collaborator
There was a problem hiding this comment.
Can these Exception be more specific? I think It should be some String exception
Changed catch blocks to catch IllegalArgumentException instead of generic Exception when calling UserAgent.sanitize(). This is the specific exception thrown by sanitize() when it encounters invalid characters in user agent strings. Addresses PR review comment.
samikshya-db
approved these changes
Jan 12, 2026
gopalldb
enabled auto-merge (squash)
January 12, 2026 05:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Custom user agent from useragententry parameter wasn't included in connector service HTTP requests for feature flag retrieval.
Root Cause
Method execution order issue in UserAgentManager.setUserAgent() - custom user agent was set AFTER the connector service request was made.
Solution
Reordered the method to set custom user agent before calling getClientUserAgent() (which triggers feature flag fetch).
Testing
NO_CHANGELOG=true