Skip to content

Commit 33439c5

Browse files
committed
fix(databricks): properly verify credentials
1 parent 51f45b7 commit 33439c5

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/backend/.env-example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ GATHERSG_PUBLIC_KEY=gathersg-public-key
7474
# DATABRICKS
7575
DATABRICKS_SERVER_HOSTNAME=...
7676
DATABRICKS_HTTP_PATH=...
77-
DATABRICKS_CATALOG=...
77+
DATABRICKS_CATALOG=...

packages/backend/src/apps/databricks/auth/verify-credentials.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,33 @@ import { IGlobalVariable } from '@plumber/types'
33
import { ZodError } from 'zod'
44
import { fromZodError } from 'zod-validation-error'
55

6+
import { databricksConfig } from '@/config/app-env-vars/databricks'
7+
import logger from '@/helpers/logger'
8+
69
import { validateAuthData } from './auth-data'
710
import { createClient } from './create-client'
811

912
const verifyCredentials = async ($: IGlobalVariable) => {
1013
try {
1114
validateAuthData($)
1215
const client = await createClient($)
16+
const session = await client.openSession({
17+
initialCatalog: databricksConfig.catalog,
18+
})
19+
await session.close()
1320
await client.close()
1421
} catch (error) {
1522
if (error instanceof ZodError) {
1623
// Auth data validation failed: throws message from first error
1724
throw new Error(fromZodError(error).details[0].message)
1825
}
26+
if (error.response?.status === 401) {
27+
logger.info({
28+
event: 'databricks-verify-credentials',
29+
error: error,
30+
})
31+
throw new Error('Invalid credentials')
32+
}
1933
throw error
2034
}
2135
}

0 commit comments

Comments
 (0)