Skip to content

Commit e7bfe31

Browse files
committed
fix(credentials): report an oversized Databricks token reply as oversized
1 parent d948459 commit e7bfe31

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎apps/sim/lib/credentials/databricks-service-account.server.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ describe('getting a Databricks token for a run', () => {
189189
})
190190
})
191191

192+
it('reports a token reply over the size cap as oversized, not as a refused request', async () => {
193+
fetch.mockResolvedValue(jsonResponse({ access_token: 't'.repeat(1024 * 1024) }, 200))
194+
195+
await expect(resolveDatabricksCredentialToken('cred-1')).rejects.toMatchObject({
196+
code: 'provider_unavailable',
197+
logDetail: { reason: 'Databricks token response exceeded the size limit' },
198+
})
199+
})
200+
192201
it('reports a token reply without a token as the provider misbehaving, not a bad credential', async () => {
193202
fetch.mockResolvedValue(jsonResponse({}, 200))
194203

‎apps/sim/lib/credentials/databricks-service-account.server.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,13 @@ async function requestWorkspaceToken(
149149
const payload = (await readResponseJsonWithLimit(response, {
150150
maxBytes: MAX_RESPONSE_BYTES,
151151
label: 'Databricks token response',
152-
}).catch(() => ({}))) as {
152+
}).catch((error: unknown) => {
153+
if (error instanceof SyntaxError) return {}
154+
throw new DatabricksCredentialError(
155+
'Databricks token response exceeded the size limit',
156+
response.status
157+
)
158+
})) as {
153159
access_token?: unknown
154160
error_description?: unknown
155161
error?: unknown

0 commit comments

Comments
 (0)