Skip to content

fix: handle COLINFO (0xA5) and TABNAME (0xA4) TDS tokens returned by tables with triggers#343

Merged
shueybubbles merged 4 commits into
mainfrom
copilot/fix-invalid-tds-stream-error
Mar 27, 2026
Merged

fix: handle COLINFO (0xA5) and TABNAME (0xA4) TDS tokens returned by tables with triggers#343
shueybubbles merged 4 commits into
mainfrom
copilot/fix-invalid-tds-stream-error

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 26, 2026

  • Add tokenTabName (0xA4 = 164) and tokenColInfo (0xA5 = 165) token constants to token.go
  • Add parseTabName function that reads and discards the TABNAME token stream
  • Add parseColInfo function that reads and discards the COLINFO token stream
  • Add cases for both new tokens in the processSingleResponse switch statement
  • Update token_string.go to include the new token names
  • TestParseColInfo — happy-path subtests (empty, with data) + "truncated stream panics" subtest for 100% coverage of parseColInfo
  • TestParseTabName — happy-path subtests (empty, with data) + "truncated stream panics" subtest for 100% coverage of parseTabName
  • TestTokenString — verifies tokenTabName.String() and tokenColInfo.String() return the correct names, covering the new cases in token_string.go
  • TestProcessSingleResponseWithTriggerTableTokens — full integration test via real TDS packet
  • All functions reach 100% statement coverage from unit tests

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…triggers

Agent-Logs-Url: https://github.com/microsoft/go-mssqldb/sessions/b95eb330-ed57-4d40-ba5b-7979e2daeae8

Co-authored-by: shueybubbles <2224906+shueybubbles@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix INSERT operation error with triggers on table fix: handle COLINFO (0xA5) and TABNAME (0xA4) TDS tokens returned by tables with triggers Mar 26, 2026
Copilot AI requested a review from shueybubbles March 26, 2026 19:59
@shueybubbles
Copy link
Copy Markdown
Collaborator

@copilot add a test

…sSingleResponse integration test

Agent-Logs-Url: https://github.com/microsoft/go-mssqldb/sessions/2c4e56ea-bbaf-416d-a069-a29c3dfa8498

Co-authored-by: shueybubbles <2224906+shueybubbles@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 26, 2026

@copilot add a test

Added three tests in commit c5663af:

  • TestParseColInfo — unit tests for the new parseColInfo function with empty and non-empty payloads
  • TestParseTabName — unit tests for the new parseTabName function with empty and non-empty payloads
  • TestProcessSingleResponseWithTriggerTableTokens — constructs a real TDS reply packet containing COLINFO + TABNAME tokens followed by a DONE token, runs it through processSingleResponse, and verifies no error is returned (this test would have failed before the fix with "unknown token type returned: token(165)")

@shueybubbles shueybubbles marked this pull request as ready for review March 26, 2026 20:33
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.91%. Comparing base (2be611f) to head (5d70dde).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #343      +/-   ##
==========================================
+ Coverage   79.80%   79.91%   +0.11%     
==========================================
  Files          34       34              
  Lines        6600     6623      +23     
==========================================
+ Hits         5267     5293      +26     
+ Misses       1062     1061       -1     
+ Partials      271      269       -2     
Files with missing lines Coverage Δ
token.go 68.70% <100.00%> (+0.35%) ⬆️
token_string.go 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dlevy-msft-sql
Copy link
Copy Markdown

@copilot that codecov report needs some work

…token String() method

Agent-Logs-Url: https://github.com/microsoft/go-mssqldb/sessions/a28943f0-dfb0-43f3-9ccd-ae25d1f0b2b6

Co-authored-by: dlevy-msft-sql <194277063+dlevy-msft-sql@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 26, 2026

@copilot that codecov report needs some work

Improved coverage in commit 5d70dde. parseColInfo and parseTabName are now at 100%:

  • Added "truncated stream panics" subtests to TestParseColInfo and TestParseTabName — these construct a buffer where the declared size exceeds the available bytes, triggering the badStreamPanic(err) error path that was previously uncovered (66.7% → 100%)
  • Added TestTokenString — exercises tokenTabName.String() and tokenColInfo.String(), covering the new cases in token_string.go
  • Extracted makeFinalBuf() helper (sets final: true so the buffer returns io.EOF when exhausted rather than panicking on a nil transport)

@shueybubbles shueybubbles merged commit 7c905ad into main Mar 27, 2026
11 checks passed
@shueybubbles shueybubbles deleted the copilot/fix-invalid-tds-stream-error branch March 27, 2026 00:33
AbbasLB pushed a commit to AbbasLB/go-mssqldb that referenced this pull request Apr 10, 2026
…tables with triggers (microsoft#343)

* Initial plan

* fix: handle COLINFO (0xA5) and TABNAME (0xA4) tokens for tables with triggers

Agent-Logs-Url: https://github.com/microsoft/go-mssqldb/sessions/b95eb330-ed57-4d40-ba5b-7979e2daeae8

Co-authored-by: shueybubbles <2224906+shueybubbles@users.noreply.github.com>

* test: add unit tests for COLINFO and TABNAME token parsing and processSingleResponse integration test

Agent-Logs-Url: https://github.com/microsoft/go-mssqldb/sessions/2c4e56ea-bbaf-416d-a069-a29c3dfa8498

Co-authored-by: shueybubbles <2224906+shueybubbles@users.noreply.github.com>

* test: improve coverage for parseColInfo/parseTabName error paths and token String() method

Agent-Logs-Url: https://github.com/microsoft/go-mssqldb/sessions/a28943f0-dfb0-43f3-9ccd-ae25d1f0b2b6

Co-authored-by: dlevy-msft-sql <194277063+dlevy-msft-sql@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: shueybubbles <2224906+shueybubbles@users.noreply.github.com>
Co-authored-by: dlevy-msft-sql <194277063+dlevy-msft-sql@users.noreply.github.com>
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.

4 participants