这是indexloc提供的服务,不要输入任何密码
Skip to content

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

@CptPirx

Description

@CptPirx

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    possible bugBug was reported but is not confirmed or is unable to be replicated.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions