Skip to content

fix: strip only the driver prefix from an info message - #448

Merged
TimelordUK merged 1 commit into
masterfrom
fix/info-message-prefix
Sep 9, 2026
Merged

fix: strip only the driver prefix from an info message#448
TimelordUK merged 1 commit into
masterfrom
fix/info-message-prefix

Conversation

@TimelordUK

Copy link
Copy Markdown
Owner

res.info reports a diagnostic with the driver's component chain removed, e.g. "[Microsoft][ODBC Driver 18 for SQL Server][SQL Server]". It was removed by cutting at the last ']' anywhere in the string, so any message carrying a bracket of its own lost everything up to it:

print 'select * from [dbo].[my_table]' -> ''
print 'ends with ]' -> ''

Generated SQL is largely bracketed identifiers, so this hit the common reason to PRINT anything, and it hit every caller of the promises api because they all aggregate through here. The whole message was lost, silently, with nothing left to suggest the text had ever been there.

The chain is now matched at the start of the message rather than searched for at the end. Components from the drivers and managers we know - Microsoft, the ODBC Driver Manager, ODBC Driver NN for SQL Server, SQL Server, the Native Client names, unixODBC and iODBC - are removed one after another, which leaves a message that itself opens with a bracketed identifier intact. Anything else still gets its leading chain of bracketed groups removed, so an unrecognised driver such as FreeTDS is no worse off than before; a message of its own that opens with a bracket is the one case that cannot be told apart from a component, and losing a leading group beats losing the whole line.

stripDriverPrefix is exported so the conversion can be tested without a server.

Claude-Session: https://claude.ai/code/session_01FS9t73svfSHXWoBUehTKA2

res.info reports a diagnostic with the driver's component chain removed, e.g.
"[Microsoft][ODBC Driver 18 for SQL Server][SQL Server]". It was removed by
cutting at the last ']' anywhere in the string, so any message carrying a bracket
of its own lost everything up to it:

  print 'select * from [dbo].[my_table]'   ->   ''
  print 'ends with ]'                      ->   ''

Generated SQL is largely bracketed identifiers, so this hit the common reason to
PRINT anything, and it hit every caller of the promises api because they all
aggregate through here. The whole message was lost, silently, with nothing left to
suggest the text had ever been there.

The chain is now matched at the start of the message rather than searched for at
the end. Components from the drivers and managers we know - Microsoft, the ODBC
Driver Manager, ODBC Driver NN for SQL Server, SQL Server, the Native Client
names, unixODBC and iODBC - are removed one after another, which leaves a message
that itself opens with a bracketed identifier intact. Anything else still gets its
leading chain of bracketed groups removed, so an unrecognised driver such as
FreeTDS is no worse off than before; a message of its own that opens with a
bracket is the one case that cannot be told apart from a component, and losing a
leading group beats losing the whole line.

stripDriverPrefix is exported so the conversion can be tested without a server.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FS9t73svfSHXWoBUehTKA2
@TimelordUK
TimelordUK merged commit c993c5e into master Sep 9, 2026
10 checks passed
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.

1 participant