[GH-ISSUE #4040] [BUG]: SQL Connector: TypeError: Cannot read properties of undefined (reading '0') #2570

Closed
opened 2026-02-22 18:30:18 -05:00 by yindo · 1 comment
Owner

Originally created by @CesareIsHere on GitHub (Jun 24, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/4040

Originally assigned to: @shatfield4, @timothycarambat on GitHub.

How are you running AnythingLLM?

Docker (local)

What happened?

I'm hosting anythingllm on docker on an Ubuntu Azure VM.

I configure sql connector using sqlserver odbc with configuration like this:

Image

But when i ask to the agent something i get this error:

[backend] info: [AgentHandler] [debug]: @agent is attempting to call `sql-list-databases` tool
[backend] info: [AgentHandler] Using the sql-list-databases tool.
[backend] info: [AgentHandler] [debug]: @agent is attempting to call `sql-list-tables` tool
[backend] info: [AgentHandler] Using the sql-list-tables tool.
[backend] error: TypeError: Cannot read properties of undefined (reading '0')
    at #parseDatabase (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:46:28)
    at new MSSQLConnector (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:33:24)
    at getDBClient (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/index.js:38:14)
    at Object.handler (/app/server/utils/agents/aibitat/plugins/sql-agent/list-table.js:59:26)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:663:14)
    at async AIbitat.reply (/app/server/utils/agents/aibitat/index.js:589:21)
    at async AIbitat.chat (/app/server/utils/agents/aibitat/index.js:387:15)
    at async AIbitat.continue (/app/server/utils/agents/aibitat/index.js:715:7)
    at async EventEmitter.<anonymous> (/app/server/utils/agents/aibitat/plugins/websocket.js:105:11)

And this in the UI:

Image

thank you for the help.

Are there known steps to reproduce?

No response

Originally created by @CesareIsHere on GitHub (Jun 24, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/4040 Originally assigned to: @shatfield4, @timothycarambat on GitHub. ### How are you running AnythingLLM? Docker (local) ### What happened? I'm hosting anythingllm on docker on an Ubuntu Azure VM. I configure sql connector using sqlserver odbc with configuration like this: ![Image](https://github.com/user-attachments/assets/3baaa9c7-b3e2-4e8d-9a23-3f45ec7c75d2) But when i ask to the agent something i get this error: ``` [backend] info: [AgentHandler] [debug]: @agent is attempting to call `sql-list-databases` tool [backend] info: [AgentHandler] Using the sql-list-databases tool. [backend] info: [AgentHandler] [debug]: @agent is attempting to call `sql-list-tables` tool [backend] info: [AgentHandler] Using the sql-list-tables tool. [backend] error: TypeError: Cannot read properties of undefined (reading '0') at #parseDatabase (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:46:28) at new MSSQLConnector (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:33:24) at getDBClient (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/index.js:38:14) at Object.handler (/app/server/utils/agents/aibitat/plugins/sql-agent/list-table.js:59:26) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:663:14) at async AIbitat.reply (/app/server/utils/agents/aibitat/index.js:589:21) at async AIbitat.chat (/app/server/utils/agents/aibitat/index.js:387:15) at async AIbitat.continue (/app/server/utils/agents/aibitat/index.js:715:7) at async EventEmitter.<anonymous> (/app/server/utils/agents/aibitat/plugins/websocket.js:105:11) ``` And this in the UI: ![Image](https://github.com/user-attachments/assets/fd358d15-3541-469f-a432-e83bfca102c4) thank you for the help. ### Are there known steps to reproduce? _No response_
yindo added the possible bug label 2026-02-22 18:30:18 -05:00
yindo closed this issue 2026-02-22 18:30:18 -05:00
Author
Owner

@anytrace-ai-support-engineer-yc-s25 commented on GitHub (Jun 28, 2025):

Investigation Summary

I was able to reproduce this issue.
This happens because MSSQLConnector.#parseDatabase() blindly indexes parsed.hosts[0] without first checking that the RegEx parser actually found a host (https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js#L46-L47).

Verified steps

Reproduction

  1. Created SQLServer locally.
  2. Started anything-llm docker container locally.
  3. Created SQLConnector to connect the AnythingLLM Workspace to the local SQLServer instance.
  4. Prompt "@agent what is in my sql table?".
  5. Confirm the same error and backend logs:
[backend] error: TypeError: Cannot read properties of undefined (reading '0')
at #parseDatabase (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:46:28)
at new MSSQLConnector (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:33:24)
at getDBClient (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/index.js:38:14)
at Object.handler (/app/server/utils/agents/aibitat/plugins/sql-agent/list-table.js:59:26)
at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22)
at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:663:14)
at async AIbitat.reply (/app/server/utils/agents/aibitat/index.js:589:21)
at async AIbitat.chat (/app/server/utils/agents/aibitat/index.js:387:15)
at async AIbitat.start (/app/server/utils/agents/aibitat/index.js:321:5)
at async /app/server/endpoints/agentWebsocket.js:52:7

Next steps for @CesareIsHere

N/A

Next steps for Multiplex-Labs

Revise the logic in MSSQLConnector.#parseDatabase(). Consider the fix MSSQLConnector.#parseDatabase():

-      server: parsed?.hosts[0]?.host,
-      port: parsed?.hosts[0]?.port,
+      server: parsed?.hosts?.[0]?.host,
+      port: parsed?.hosts?.[0]?.port,

@timothycarambat @Mintplex-Labs

If you'd like Anytrace (YC S25) to keep investigating your support tickets, reach out to taira@anytrace.ai to discuss how we can keep supporting your team!

@anytrace-ai-support-engineer-yc-s25 commented on GitHub (Jun 28, 2025): ### Investigation Summary I was able to reproduce this issue. This happens because `MSSQLConnector.#parseDatabase()` blindly indexes `parsed.hosts[0]` without first checking that the RegEx parser actually found a host (https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js#L46-L47). ### Verified steps #### Reproduction 1. Created SQLServer locally. 2. Started anything-llm docker container locally. 3. Created SQLConnector to connect the AnythingLLM Workspace to the local SQLServer instance. 4. Prompt "@agent what is in my sql table?". 5. Confirm the same error and backend logs: ``` [backend] error: TypeError: Cannot read properties of undefined (reading '0') at #parseDatabase (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:46:28) at new MSSQLConnector (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/MSSQL.js:33:24) at getDBClient (/app/server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/index.js:38:14) at Object.handler (/app/server/utils/agents/aibitat/plugins/sql-agent/list-table.js:59:26) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:663:14) at async AIbitat.reply (/app/server/utils/agents/aibitat/index.js:589:21) at async AIbitat.chat (/app/server/utils/agents/aibitat/index.js:387:15) at async AIbitat.start (/app/server/utils/agents/aibitat/index.js:321:5) at async /app/server/endpoints/agentWebsocket.js:52:7 ``` ### Next steps for @CesareIsHere N/A ### Next steps for Multiplex-Labs Revise the logic in `MSSQLConnector.#parseDatabase()`. Consider the fix `MSSQLConnector.#parseDatabase()`: ``` - server: parsed?.hosts[0]?.host, - port: parsed?.hosts[0]?.port, + server: parsed?.hosts?.[0]?.host, + port: parsed?.hosts?.[0]?.port, ``` ### @timothycarambat @Mintplex-Labs If you'd like Anytrace (YC S25) to keep investigating your support tickets, reach out to taira@anytrace.ai to discuss how we can keep supporting your team!
yindo changed title from [BUG]: SQL Connector: TypeError: Cannot read properties of undefined (reading '0') to [GH-ISSUE #4040] [BUG]: SQL Connector: TypeError: Cannot read properties of undefined (reading '0') 2026-06-05 14:47:18 -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#2570