[GH-ISSUE #3551] [BUG]: Microsoft SQL Server Connector - parsing error #2287

Closed
opened 2026-02-22 18:29:00 -05:00 by yindo · 5 comments
Owner

Originally created by @CptPirx on GitHub (Mar 27, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3551

How are you running AnythingLLM?

Docker (remote machine)

What happened?

Problem description

In Agent Skills -> SQL Connectors I have configured connections to 2 MS SQL Server databases. Let's call them database A and database B. Anything-llm and SQL Server are running on the same local network.
Anything-llm runs on our kubernetes cluster.

When I ask the @agent about the database A, I get correct results. The logs in my container indicate everything is correct as well.

However, when I connect to database B, I get errors:

[backend] info: MSSQLConnector TypeError: The "config.server" property is required and must be of type string. 
at new Connection (/app/server/node_modules/tedious/lib/connection.js:275:13)
at /app/server/node_modules/mssql/lib/tedious/connection-pool.js:78:19
at new Promise (<anonymous>)
at ConnectionPool._poolCreate (/app/server/node_modules/mssql/lib/tedious/connection-pool.js:67:12)
at ConnectionPool._connect (/app/server/node_modules/mssql/lib/base/connection-pool.js:446:10)
at /app/server/node_modules/mssql/lib/base/connection-pool.js:418:19
at new Promise (<anonymous>)
at ConnectionPool.connect (/app/server/node_modules/mssql/lib/base/connection-pool.js:417:12)
at Object.connect (/app/server/node_modules/mssql/lib/global-connection.js:59:27)
at MSSQLConnector.connect (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:53:32)    

[backend] error: TypeError: Cannot read properties of null (reading 'close')
at MSSQLConnector.runQuery (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:75:26)
at async Object.handler (/app/server/utils/agents/aibitat/plugins/sql-agent/list-table.js:65:30)
at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:634:22)
at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:636:14)
at async AIbitat.reply (/app/server/utils/agents/aibitat/index.js:578:21)
at async AIbitat.chat (/app/server/utils/agents/aibitat/index.js:374:15)
at async AIbitat.start (/app/server/utils/agents/aibitat/index.js:308:5)
at async /app/server/endpoints/agentWebsocket.js:52:7  

I'm sure that the connection details for database B are correct. I can use them with success in other applications, etc.

Details

Database A

  • SQL Server 2017 (14.0.3490.10)

Database B

  • SQL Server 2016 (13.0.7050.2)

Verification steps taken

On our Kubernetes cluster, we've created a shell script that uses the newest mssql library to test the connection.

const sql = require('mssql')
const config = {
    user: '****,
    password: '****',
    server: '****',
    database: 'B',
    port: 1433,
    pool: {
        max: 10,
        min: 0,
        idleTimeoutMillis: 30000,
    },
    options: {
        encrypt: false,
        trustServerCertificate: true
    }
}
async function testConnection() {
    try {
        console.log('Próba połączenia...');
        const pool = await sql.connect(config);
        console.log('Połączenie udane!');
        const result = await pool.request()
            .query('SELECT COUNT(*) as count FROM Units');
        console.log('Wynik zapytania:', result.recordset[0].count);
        await sql.close();
    } catch (err) {
        console.error('Błąd:', err);
    }
}
testConnection();
// Czekamy 10 sekund przed zakończeniem
setTimeout(() => {
    console.log('Kończę test...');
    process.exit(0);
}, 10000)

The script conencts to the database B successfully.

Furthermore, we have investigated the Anything-llm code responsible for connecting to the SQL database:

https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js

The script appears to use very similar method to our script. However, it does not work for database B.

Are there known steps to reproduce?

No response

Originally created by @CptPirx on GitHub (Mar 27, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3551 ### How are you running AnythingLLM? Docker (remote machine) ### What happened? # Problem description In Agent Skills -> SQL Connectors I have configured connections to 2 MS SQL Server databases. Let's call them database A and database B. Anything-llm and SQL Server are running on the same local network. Anything-llm runs on our kubernetes cluster. When I ask the @agent about the database A, I get correct results. The logs in my container indicate everything is correct as well. However, when I connect to database B, I get errors: ``` [backend] info: MSSQLConnector TypeError: The "config.server" property is required and must be of type string. at new Connection (/app/server/node_modules/tedious/lib/connection.js:275:13) at /app/server/node_modules/mssql/lib/tedious/connection-pool.js:78:19 at new Promise (<anonymous>) at ConnectionPool._poolCreate (/app/server/node_modules/mssql/lib/tedious/connection-pool.js:67:12) at ConnectionPool._connect (/app/server/node_modules/mssql/lib/base/connection-pool.js:446:10) at /app/server/node_modules/mssql/lib/base/connection-pool.js:418:19 at new Promise (<anonymous>) at ConnectionPool.connect (/app/server/node_modules/mssql/lib/base/connection-pool.js:417:12) at Object.connect (/app/server/node_modules/mssql/lib/global-connection.js:59:27) at MSSQLConnector.connect (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:53:32) [backend] error: TypeError: Cannot read properties of null (reading 'close') at MSSQLConnector.runQuery (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:75:26) at async Object.handler (/app/server/utils/agents/aibitat/plugins/sql-agent/list-table.js:65:30) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:634:22) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:636:14) at async AIbitat.reply (/app/server/utils/agents/aibitat/index.js:578:21) at async AIbitat.chat (/app/server/utils/agents/aibitat/index.js:374:15) at async AIbitat.start (/app/server/utils/agents/aibitat/index.js:308:5) at async /app/server/endpoints/agentWebsocket.js:52:7 ``` I'm sure that the connection details for database B are correct. I can use them with success in other applications, etc. ## Details ### Database A * SQL Server 2017 (14.0.3490.10) ### Database B * SQL Server 2016 (13.0.7050.2) ## Verification steps taken On our Kubernetes cluster, we've created a shell script that uses the newest mssql library to test the connection. ``` const sql = require('mssql') const config = { user: '****, password: '****', server: '****', database: 'B', port: 1433, pool: { max: 10, min: 0, idleTimeoutMillis: 30000, }, options: { encrypt: false, trustServerCertificate: true } } async function testConnection() { try { console.log('Próba połączenia...'); const pool = await sql.connect(config); console.log('Połączenie udane!'); const result = await pool.request() .query('SELECT COUNT(*) as count FROM Units'); console.log('Wynik zapytania:', result.recordset[0].count); await sql.close(); } catch (err) { console.error('Błąd:', err); } } testConnection(); // Czekamy 10 sekund przed zakończeniem setTimeout(() => { console.log('Kończę test...'); process.exit(0); }, 10000) ``` The script conencts to the database B successfully. Furthermore, we have investigated the Anything-llm code responsible for connecting to the SQL database: https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js The script appears to use very similar method to our script. However, it does not work for database B. ### Are there known steps to reproduce? _No response_
yindo added the possible bug label 2026-02-22 18:29:00 -05:00
yindo closed this issue 2026-02-22 18:29:00 -05:00
Author
Owner

@timothycarambat commented on GitHub (Mar 27, 2025):

I am assuming the server part of Database A is more easily parsed than Database B since
https://github.com/Mintplex-Labs/anything-llm/blob/b6698ff89e2c7d4c587e6a3295759328da94f156/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js#L47C7-L47C27

Is where config.server is set and the root error is

[backend] info: MSSQLConnector TypeError: The "config.server" property is required and must be of type string.

So it would appear that the Regex for the connection string is failing to match the arbitrary group that we use for the server - which we do because a server can be any valid IP/URL/Host/Subdomain

If you can share two example database strings in the same structure - that would help. Might be something to do with parsing IP/host/subdomains or something else. Obviously do not share the real connection strings - just something that pattern-matches the same one so we can debug the regex as a "normal" RDS host, for example, works as is. So it is something along those lines that needs to be handled.

@timothycarambat commented on GitHub (Mar 27, 2025): I am assuming the `server` part of Database A is more easily parsed than Database B since https://github.com/Mintplex-Labs/anything-llm/blob/b6698ff89e2c7d4c587e6a3295759328da94f156/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js#L47C7-L47C27 Is where `config.server` is set and the root error is > [backend] info: MSSQLConnector TypeError: The "config.server" property is required and must be of type string. So it would appear that the Regex for the connection string is failing to match the arbitrary group that we use for the server - which we do because a server can be any valid IP/URL/Host/Subdomain If you can share two _example_ database strings in the same structure - that would help. Might be something to do with parsing IP/host/subdomains or something else. **Obviously do not share the real connection strings** - just something that pattern-matches the same one so we can debug the regex as a "normal" RDS host, for example, works as is. So it is something along those lines that needs to be handled.
Author
Owner

@CptPirx commented on GitHub (Mar 28, 2025):

Here are the randomized connection strings. They preserve special symbols and patterns.

  • Database A: mssql://jkl:xy_abcd3xyz@random.newdomain.local:1443

  • Database B: mssql://xyz:abc$4567@random.newdomain.local:1433

@CptPirx commented on GitHub (Mar 28, 2025): Here are the randomized connection strings. They preserve special symbols and patterns. * Database A: mssql://jkl:xy_abcd3xyz@random.newdomain.local:1443 * Database B: mssql://xyz:abc$4567@random.newdomain.local:1433
Author
Owner

@CptPirx commented on GitHub (Apr 2, 2025):

Hi, I've updated our image to 1.7.8. Unfortunately, we still have the same issue:

[backend] info: [AgentHandler] Using the sql-list-tables tool.
[backend] info: MSSQLConnector TypeError: The "config.server" property is required and must be of type string.
    at new Connection (/app/server/node_modules/tedious/lib/connection.js:275:13)
    at /app/server/node_modules/mssql/lib/tedious/connection-pool.js:78:19
    at new Promise (<anonymous>)
    at ConnectionPool._poolCreate (/app/server/node_modules/mssql/lib/tedious/connection-pool.js:67:12)
    at ConnectionPool._connect (/app/server/node_modules/mssql/lib/base/connection-pool.js:446:10)
    at /app/server/node_modules/mssql/lib/base/connection-pool.js:418:19
    at new Promise (<anonymous>)
    at ConnectionPool.connect (/app/server/node_modules/mssql/lib/base/connection-pool.js:417:12)
    at Object.connect (/app/server/node_modules/mssql/lib/global-connection.js:59:27)
    at MSSQLConnector.connect (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:53:32)
[backend] error: TypeError: Cannot read properties of null (reading 'close')
    at MSSQLConnector.runQuery (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:75:26)
    at async Object.handler (/app/server/utils/agents/aibitat/plugins/sql-agent/list-table.js:65:30)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:634:22)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:636:14)
    at async AIbitat.reply (/app/server/utils/agents/aibitat/index.js:578:21)
    at async AIbitat.chat (/app/server/utils/agents/aibitat/index.js:374:15)
    at async AIbitat.continue (/app/server/utils/agents/aibitat/index.js:688:7)
    at async EventEmitter.<anonymous> (/app/server/utils/agents/aibitat/plugins/websocket.js:110:11)

Image version, screen from k9s:

Image

@CptPirx commented on GitHub (Apr 2, 2025): Hi, I've updated our image to 1.7.8. Unfortunately, we still have the same issue: ``` [backend] info: [AgentHandler] Using the sql-list-tables tool. [backend] info: MSSQLConnector TypeError: The "config.server" property is required and must be of type string. at new Connection (/app/server/node_modules/tedious/lib/connection.js:275:13) at /app/server/node_modules/mssql/lib/tedious/connection-pool.js:78:19 at new Promise (<anonymous>) at ConnectionPool._poolCreate (/app/server/node_modules/mssql/lib/tedious/connection-pool.js:67:12) at ConnectionPool._connect (/app/server/node_modules/mssql/lib/base/connection-pool.js:446:10) at /app/server/node_modules/mssql/lib/base/connection-pool.js:418:19 at new Promise (<anonymous>) at ConnectionPool.connect (/app/server/node_modules/mssql/lib/base/connection-pool.js:417:12) at Object.connect (/app/server/node_modules/mssql/lib/global-connection.js:59:27) at MSSQLConnector.connect (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:53:32) [backend] error: TypeError: Cannot read properties of null (reading 'close') at MSSQLConnector.runQuery (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:75:26) at async Object.handler (/app/server/utils/agents/aibitat/plugins/sql-agent/list-table.js:65:30) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:634:22) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:636:14) at async AIbitat.reply (/app/server/utils/agents/aibitat/index.js:578:21) at async AIbitat.chat (/app/server/utils/agents/aibitat/index.js:374:15) at async AIbitat.continue (/app/server/utils/agents/aibitat/index.js:688:7) at async EventEmitter.<anonymous> (/app/server/utils/agents/aibitat/plugins/websocket.js:110:11) ``` Image version, screen from k9s: ![Image](https://github.com/user-attachments/assets/7967b3c6-e5b4-4f08-aea7-7a64a9a1e999)
Author
Owner

@timothycarambat commented on GitHub (Apr 2, 2025):

Because it was merged after 1.7.8 - it is only currently available under latest
https://github.com/Mintplex-Labs/anything-llm/releases/tag/v1.7.8

@timothycarambat commented on GitHub (Apr 2, 2025): Because it was merged _after_ 1.7.8 - it is only currently available under `latest` https://github.com/Mintplex-Labs/anything-llm/releases/tag/v1.7.8
Author
Owner

@CptPirx commented on GitHub (Apr 2, 2025):

Of course, I misread the header of the release 1.7.8. Thanks!

@CptPirx commented on GitHub (Apr 2, 2025): Of course, I misread the header of the release 1.7.8. Thanks!
yindo changed title from [BUG]: Microsoft SQL Server Connector - parsing error to [GH-ISSUE #3551] [BUG]: Microsoft SQL Server Connector - parsing error 2026-06-05 14:45:40 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#2287