Skip to content

Commit 499f86d

Browse files
committed
fix: THTTPException error handling
1 parent b8c1642 commit 499f86d

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

.changeset/chubby-trees-remain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"ansible-database-mcp": patch
3+
---
4+
5+
THTTPException error handling

src/services/db-connection/adapters/databricks-adapter.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,33 @@ export class DatabricksAdapter extends EventEmitter {
122122

123123
/**
124124
* Check if error is a connection-related error
125+
*
126+
* THTTPException is thrown by Databricks SQL client when HTTP transport encounters errors.
127+
* Error structure:
128+
* - name: 'THTTPException'
129+
* - statusCode: HTTP status code (e.g., 400)
130+
* - type: Thrift TApplicationException type (7 = PROTOCOL_ERROR)
131+
* - response: Node.js Response object with status details
132+
*
133+
* Common causes for statusCode 400 with type 7:
134+
* - Session expired on server side (default 15 min idle timeout)
135+
* - Client connection in stale state after long idle period
136+
* - Protocol mismatch between client and server
137+
*
138+
* Note: The Databricks SQL Node.js documentation does not provide specific error type
139+
* definitions. This error handling is based on empirical observation and Thrift protocol
140+
* specifications.
125141
*/
126142
private isConnectionError(error: any): boolean {
127143
if (!error) return false;
128144

129-
const errorMessage = error.message || '';
145+
const errorName = error.name || '';
130146
const statusCode = error.statusCode;
131147

132148
// Only check for explicit indicators
133149
return (
134150
statusCode === 400 &&
135-
errorMessage.includes('THTTPException')
151+
errorName === 'THTTPException'
136152
);
137153
}
138154

0 commit comments

Comments
 (0)