Skip to content

fix(kernel): decode a failed async status poll into the driver error - #608

Merged
vuanhphung merged 3 commits into
mainfrom
fix/kernel-async-status-error-mapping
Nov 15, 2026
Merged

vuanhphung merged 3 commits into
mainfrom
fix/kernel-async-status-error-mapping

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

On the kernel backend, two calls let a failure reach the caller as a raw Error whose message is the binding's internal envelope, for example __databricks_error__:{"code":"Internal","httpStatus":500,"message":"HTTP 500: Internal Server Error"}:

  • A failed status poll. waitUntilReady() and status() await AsyncStatement.status() directly (lib/kernel/KernelOperationBackend.ts:429, :627). This affects runAsync: true statements and default executions that outlive the server's inline wait, since executeStatementDirect then returns an AsyncStatement that is polled the same way (lib/kernel/KernelSessionBackend.ts:259-260). The databricks-driver-test RESULTFETCH-013 SEA test (a persistent HTTP 500 on GetStatementStatus) found it.
  • A failed batch fetch in hasMore() (:357-361). When hasMoreRows() runs before the first fetch, it prefetches the first batch through fetchNextBatch(), which had no error handling. That's the first call in a while (await op.hasMoreRows()) loop.

The poll now goes through a pollAsyncStatus() helper that decodes the rejection. hasMore() now handles a failure like fetchChunk(): it best-effort closes the statement, since a failed fetch leaves the napi stream unusable, then throws the decoded error. Both paths share one helper. The caller gets the mapped driver error (HiveDriverError: HTTP 500: Internal Server Error) with its bounded cause, SQLSTATE and kernelMetadata.

Verification: two new unit tests in tests/unit/kernel/execution.test.ts. The status-poll test fails on main 8ccddd0, and the hasMoreRows() test fails without the hasMore() change. Both fail with expected Error: __databricks_error__:{"code":"Inte… to be an instance of HiveDriverError and pass with the fix. npm test (1774 passing), npm run lint, npm run type-check and prettier on the changed files are clean. Live on the pecotesting warehouse (kernel 0b5d0ed), RESULTFETCH-013 [sea] (databricks/databricks-driver-test#2068) throws the envelope on main 8ccddd0. With this fix it throws HTTP 500: Internal Server Error (3 of 3 runs, plus once more on the final head). The driver-test fetchChunk, fetchAll and iterator suites (16 tests) and the RESULTFETCH group pass on [sea].

This pull request and its description were written by Isaac.

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

vuanhphung and others added 2 commits November 15, 2026 07:05
On a runAsync: true statement, waitUntilReady() and status() awaited the napi AsyncStatement.status() without decodeNapiKernelError, so a failed poll (for example, retries exhausted on HTTP 500) reached the caller as a raw Error whose message is the __databricks_error__:{...} envelope. Decode it like the other napi calls.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
… changelog scope

The unit test now also checks kernelMetadata.httpStatus and the bounded cause. The changelog notes that a default execution that outlives the server's inline wait polls the same status() and was affected too, and adds the PR number.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

hasMore() prefetches the next batch through the napi fetchNextBatch(), so when hasMoreRows() runs before the first fetch, a failed fetch reached the caller as the raw __databricks_error__:{...} envelope. Handle it like fetchChunk(): best-effort close the wedged statement, then throw the decoded error. Both paths now share one helper.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

@vuanhphung
vuanhphung added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit 91a64ff Nov 15, 2026
23 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — 4e7521a5 Deployed Nov 15, 2026 by vuanhphung via e2e-test (22.23.4, 22_23_4) #2035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant