Skip to content

Add Feature Extension for User Agent #3451

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

samsharma2700
Copy link
Contributor

@samsharma2700 samsharma2700 commented Jun 27, 2025

Description

Adding support for User Agent Feature Extension(part 1) according to design doc here(https://microsoft.sharepoint-df.com/:w:/t/sqldevx/ERIWTt0zlCxLroNHyaPlKYwBI_LNSff6iy_wXZ8xX6nctQ?e=iP8q75):

  • Introducing necessary constants.
  • Added function to write appropriate packet data.
  • Added Unit tests for the changes

Part 2 will include the userAgentJsonPayload related implementations followed by functional tests.

Testing

Builds are passing.
Unit tests are passing.

@Copilot Copilot AI review requested due to automatic review settings June 27, 2025 01:01
@samsharma2700 samsharma2700 requested a review from a team as a code owner June 27, 2025 01:01
Copy link
Contributor

@Copilot 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

Adds initial support for the User Agent feature extension by defining new constants, extending the TDS writer with a method to serialize the user-agent payload, and toggling the feature flag in the login flow under debug builds.

  • Introduce FEATUREEXT_USERAGENT and SUPPORTED_USER_AGENT_VERSION constants and enum entry
  • Add WriteUserAgentFeatureRequest in both netfx and netcore TdsParser implementations
  • Add IsUserAgentEnabled flag and debug-only enabling logic in SqlInternalConnectionTds

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs Added user-agent feature ID constant and enum mapping
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs Implemented WriteUserAgentFeatureRequest
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs Implemented WriteUserAgentFeatureRequest
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs Added IsUserAgentEnabled flag and debug-only gating
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs Added IsUserAgentEnabled flag and debug-only gating
Comments suppressed due to low confidence (1)

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs:8715

  • The new WriteUserAgentFeatureRequest method lacks accompanying unit tests; please add tests to verify both length calculation and correct byte output in write and length-only modes.
        internal int WriteUserAgentFeatureRequest(byte[] userAgentJsonPayload,

Copy link
Contributor

@apoorvdeshmukh apoorvdeshmukh left a comment

Choose a reason for hiding this comment

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

We should add a test case validating the login request. You can refer to TestConnWithVectorFeatExtVersionNegotiation to check how to inspect login packet.

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

One minor fix.

Copy link

codecov bot commented Jun 27, 2025

Codecov Report

Attention: Patch coverage is 55.55556% with 8 lines in your changes missing coverage. Please review.

Project coverage is 67.59%. Comparing base (df35633) to head (c3bacb9).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../netcore/src/Microsoft/Data/SqlClient/TdsParser.cs 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3451      +/-   ##
==========================================
+ Coverage   63.30%   67.59%   +4.28%     
==========================================
  Files         280      280              
  Lines       62386    62417      +31     
==========================================
+ Hits        39493    42188    +2695     
+ Misses      22893    20229    -2664     
Flag Coverage Δ
addons 92.58% <ø> (ø)
netcore 72.77% <11.11%> (+5.74%) ⬆️
netfx 66.22% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Let's get either some unit tests added (that don't require the test TDS server), or some functional tets that use TDS server. Either way, the tests should verify that we produce the correct Login payload given various byte arrays, and that we handle a variety of Login Response payloads.

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Looks good, with some minor tweaks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants