Skip to content

[6.1.9 Cherry-pick] Validate TDS parser prerequisites and invalidate malformed responses - #4981

Merged
paulmedynski merged 3 commits into
release/6.1from
dev/automation/pr-4941-to-6.1.9
Nov 16, 2026
Merged

paulmedynski merged 3 commits into
release/6.1from
dev/automation/pr-4941-to-6.1.9

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Description

Backport #4941 (b714187) to release/6.1 for 6.1.9. The cherry-pick conflicts are resolved, and the branch includes the latest release/6.1 changes.

  • Validate required row metadata, alternate-row metadata identifiers, and SSPI provider state before consuming the affected tokens. Malformed responses use the existing corrupted-stream parsing error and invalidate the connection so it cannot be reused.
  • Preserve the release branch's shared/.NET/.NET Framework parser split, applying the parser-loop guards to both target implementations.
  • Retain 44 simulated-server regression cases covering sync/async entry points, supported-pool recovery, reader transitions, packet boundaries, and valid-result controls. As approved during resolution, omit only the four pool V2 cases: release/6.1 deliberately throws NotImplementedException for that unimplemented option.
  • Adapt nullable context and pool isolation to existing release-branch facilities. Register the real-server compatibility tests explicitly in the manual-test project and use the release branch's connection construction.
  • No public API, dependencies, localized resources, or supported valid-result behavior changes. Malformed streams produce the existing InvalidOperationException parsing error, not a new SqlException contract.

Issues

Backport of #4941. Resolves the failed automated cherry-pick tracked by this PR.

Testing

  • Passed: dotnet test src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj -p:Configuration=Release -p:NuGetAudit=false --filter 'FullyQualifiedName~ParserPrerequisiteTests|FullyQualifiedName~HasRowsTests|FullyQualifiedName~TdsTokenBoundsTests|FullyQualifiedName~FeatureExtAckBoundsTests' --blame-hang-timeout 10m --logger 'console;verbosity=minimal' -- 276 passed, zero failed/skipped on each of net8.0 and net9.0, including all 44 new parser cases per framework.
  • Passed: dotnet build src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj -f net462 -p:TestTargetOS=Windowsnetfx -p:Configuration=Release -p:NuGetAudit=false -- driver and unit tests compile with zero warnings/errors. .NET Framework runtime execution was not performed on Linux.
  • Failed due to unavailable SQL Server connectivity: dotnet test src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj -p:Configuration=Release -p:TestSet=2 -p:NuGetAudit=false --filter FullyQualifiedName~ParserResultProcessingTest --blame-hang-timeout 10m --logger 'console;verbosity=minimal' -- compilation succeeded on net8.0/net9.0; all four cases per framework failed during connection opening with a network/instance error, before result assertions.
  • Blocked by existing restore/toolchain setup: dotnet build src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj -f net462 -p:TestTargetOS=Windowsnetfx -p:Configuration=Release -p:TestSet=2 -p:NuGetAudit=false -- NU1009 in existing test dependencies. Retrying with -p:AutomaticallyUseReferenceAssemblyPackages=false failed with MSB3644 (missing Framework targeting assemblies).
  • Passed: git diff --cached --check before committing.
  • The initial restore without -p:NuGetAudit=false failed because the NuGet vulnerability-data endpoint was unreachable. The property is a local validation workaround only; repository audit settings are unchanged.

Guidelines

Please review the contribution guidelines before submitting a pull request:

To resolve, run:  git cherry-pick b714187
@github-actions github-actions Bot added this to the 6.1.9 milestone Nov 3, 2026
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Nov 3, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

paulmedynski and others added 2 commits November 16, 2026 11:51
Backport #4941 for #4981, preserving the release branch parser split. Apply row and alternate-metadata validation to both target implementations and share connection invalidation.

Retain 44 simulated-server regressions and register real-server compatibility coverage. Adapt nullable context and pool isolation to release/6.1; omit unsupported pool V2 cases as approved.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@paulmedynski paulmedynski changed the title [6.1.9 Cherry-pick - CONFLICTS] Validate TDS parser prerequisites and invalidate malformed responses [6.1.9 Cherry-pick] Validate TDS parser prerequisites and invalidate malformed responses Nov 16, 2026
@paulmedynski paulmedynski added the Code Health 💊 Issues/PRs that are targeted to source code quality improvements. label Nov 16, 2026
@paulmedynski paulmedynski moved this from To triage to In review in SqlClient Board Nov 16, 2026
@paulmedynski
paulmedynski requested a balanced review from Copilot November 16, 2026 16:00
@paulmedynski
paulmedynski marked this pull request as ready for review November 16, 2026 16:02
@paulmedynski
paulmedynski requested a review from a team as a code owner November 16, 2026 16:02
@paulmedynski
paulmedynski enabled auto-merge (squash) November 16, 2026 16:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The protocol-parser and connection-invalidation backport needs maintainer review because .NET Framework was compile-only and real-server compatibility tests could not run due to connectivity failures.

No open issues 🎉

What changed in this PR

Backports #4941 to release/6.1 for 6.1.9, adding TDS parser prerequisite checks that reject malformed responses and prevent affected connections from being reused, without changing public APIs.

Changes:

  • Validate row metadata, alternate-row identifiers, and SSPI provider state across shared, .NET, and .NET Framework implementations.
  • Route invalid prerequisites through the existing corrupted-stream error and connection invalidation path.
  • Add 44 simulated-server regression cases and four real-server compatibility cases, excluding unsupported pool V2 scenarios.
File Description
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​SimulatedServerTests/​ParserPrerequisiteTests.cs Adds malformed-response, pool recovery, packet-boundary, and valid-result tests.
src/​Microsoft.Data.SqlClient/​tests/​ManualTests/​SQL/​ConnectivityTests/​ParserResultProcessingTest.cs Adds real-server coverage for nullable rows, result skipping, and connection reuse.
src/​Microsoft.Data.SqlClient/​tests/​ManualTests/​Microsoft.Data.SqlClient.ManualTesting.Tests.csproj Registers the new compatibility tests.
src/​Microsoft.Data.SqlClient/​src/​Microsoft/​Data/​SqlClient/​SqlDataReader.cs Validates alternate metadata during reader result transitions.
src/​Microsoft.Data.SqlClient/​src/​Microsoft/​Data/​SqlClient/​Parser/​Tokens/​TdsAltMetadataCollection.cs Removes the debug-only failure so callers handle unmatched identifiers consistently.
src/​Microsoft.Data.SqlClient/​src/​Microsoft/​Data/​SqlClient/​Parser/​TdsParser.cs Guards SSPI state and centralizes corrupted-stream rejection.
src/​Microsoft.Data.SqlClient/​netfx/​src/​Microsoft/​Data/​SqlClient/​Parser/​TdsParser.cs Adds row and alternate-row prerequisite checks for .NET Framework.
src/​Microsoft.Data.SqlClient/​netcore/​src/​Microsoft/​Data/​SqlClient/​Parser/​TdsParser.cs Adds equivalent prerequisite checks for .NET.

Review effort: Balanced

@paulmedynski
paulmedynski merged commit 9be6481 into release/6.1 Nov 16, 2026
282 of 283 checks passed
@paulmedynski
paulmedynski deleted the dev/automation/pr-4941-to-6.1.9 branch November 16, 2026 21:31
@github-project-automation github-project-automation Bot moved this from In review to Done in SqlClient Board Nov 16, 2026
@mdaigle mdaigle mentioned this pull request Nov 16, 2026
3 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code Health 💊 Issues/PRs that are targeted to source code quality improvements.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants