FIX: handle TransactionManager (0x0E) requests in mock TDS server - #87
Merged
Merged
Conversation
Python DB-API drivers (mssql-python, pyodbc) default to autocommit=OFF,
so after a successful FedAuth Login7 the client issues a TransactionManager
request to begin a transaction. The mock did not recognize packet type
0x0E, so PacketHeader::parse failed ("Invalid packet type: 14"), no
response was written, and the client blocked forever waiting for the
transaction reply. This surfaced as a 1-hour CI worker timeout on Linux,
where the login timeout is not honored.
Add PacketType::TransactionManager (0x0E), parse the RequestType from the
request body, and reply with a matching transaction EnvChange + Done token
so connection setup completes cleanly. Handled in both the TLS
(process_packet) and plaintext (handle_connection) dispatch paths, with
unit tests for parse/build helpers.
Fixes #86
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes the mock TDS server (mssql-mock-tds) to properly recognize and respond to TransactionManager (0x0E) packets, preventing autocommit-off clients (e.g., pyodbc, mssql-python) from hanging immediately after a successful FedAuth Login7.
Changes:
- Added
PacketType::TransactionManager = 0x0Eand decoding support inTryFrom<u8>. - Introduced
parse_transaction_manager_requestandbuild_transaction_manager_responsehelpers to parse the request type and emit anEnvChange+Donetoken stream. - Handled
TransactionManagerpackets in both server dispatch paths (TLSprocess_packetand plaintexthandle_connection) and added unit tests for the new helpers.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
mssql-mock-tds/src/server.rs |
Adds TransactionManager handling in both TLS and plaintext packet dispatch so clients receive a response instead of hanging. |
mssql-mock-tds/src/protocol.rs |
Extends packet type decoding and adds parse/build helpers plus unit tests for TransactionManager request/response behavior. |
saurabh500
marked this pull request as ready for review
July 1, 2026 00:33
Vahid-b
approved these changes
Jul 1, 2026
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changes
Summary
mssql-mock-tds/src/protocol.rsmssql-mock-tds/src/server.rs🔗 Quick Links |
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.
Summary
Fixes #86.
Python DB-API drivers such as mssql-python and pyodbc default to
autocommit=OFF. After a successful FedAuthLogin7, the ODBC driver immediately issues a TransactionManager request (TDS packet type0x0E) to begin a transaction. The mock TDS server did not recognize0x0E, soPacketHeader::parsefailed withInvalid packet type: 14, no response was written, and the client blocked forever waiting for the transaction reply.This showed up as a 1-hour CI worker timeout on Linux in the mssql-python mock-TDS FedAuth tests (the Windows login-timeout behavior masked it there).
Changes
PacketType::TransactionManager = 0x0Eto thePacketTypeenum and itsTryFrom<u8>.parse_transaction_manager_requestto read theRequestType(BEGIN/COMMIT/ROLLBACK) from the request body (skips theALL_HEADERSblock).build_transaction_manager_responseto emit a matching transactionEnvChange(Begin=8, Commit=9, Rollback=10) plus aDonetoken so connection setup completes cleanly.TransactionManagerin both dispatch paths: the TLSprocess_packetpath and the plaintexthandle_connectionpath.cargo testnow runs 16 tests).Validation
cargo fmt --check,cargo clippy, andcargo test -p mssql-mock-tdsall pass.mssql-pythonconnect against the fixed mock now logsHandling TransactionManager request (type 5), sends a response, and the client connects and closes cleanly instead of hanging. The FedAuth access token is recorded as before.