Skip to content

test(e2e): capture notebook cell errors in run_dbconnect diagnostics#2013

Open
rugpanov wants to merge 3 commits into
mainfrom
fix/run-dbconnect-e2e-diagnostics
Open

test(e2e): capture notebook cell errors in run_dbconnect diagnostics#2013
rugpanov wants to merge 3 commits into
mainfrom
fix/run-dbconnect-e2e-diagnostics

Conversation

@rugpanov

Copy link
Copy Markdown
Contributor

Summary

Makes the run_dbconnect.ucws e2e test capture why a notebook/magic cell fails, so the current flaky failures can be root-caused from CI logs instead of only from the .webm video.

Background

The ensureVenvHasKernelDeps fix (#2006) works — the kernel now starts and the notebook's first cell runs. But two failures remain (seen in run 29318458802):

  • notebook test: Notebook: Run All completes cell 1, but the 2nd cell (%run "./hello.py") never executes (video shows cell [ ], status bar "Cell 1 of 2").
  • magic test: the %sql_sqldf cell doesn't emit its output — fails on both Linux and Windows.

We couldn't see the actual cell error because dumpNotebookDiagnostics crashed enumerating Output channels:

could not list Output channels: Can't call $$ on element with selector "select[title="Tasks"]"
=== Output channels available === []

That select[title="Tasks"] locator (from wdio-vscode-service) is stale on the pinned VS Code ^1.86.0, so the kernel's traceback never reached CI logs.

What this does (diagnostics only — no product/assertion changes)

  • dumpActiveNotebookCells() — reads the active notebook's cells, execution summaries (executionOrder/success), and output items via the VS Code API through browser.executeWorkbench. No DOM selector, so a cell error/traceback or a never-run cell is captured directly.
  • dumpVscodeLogFiles() — dumps VS Code's on-disk logs (extension host + Output-channel logs) resolved from vscode.env.logUri — another selector-independent source for the kernel/DBConnect error.
  • Both run ahead of the existing Output-channel scrape, which is kept as best-effort (its failure was already caught; now clearly documented as a stale locator).
  • Runs only on the failure path, so the happy path is unaffected.

Verification

  • tsc --noEmit -p src/test/e2e/tsconfig.json: 0 errors.
  • eslint + prettier on the file: clean.
  • The e2e itself runs only in the databricks-eng CI; the purpose of this change is to make the next run capture the cell error so the underlying %run/%sql execution failure can be diagnosed and fixed as a follow-up.

This pull request and its description were written by Isaac.

*Why*
When a run_dbconnect notebook/magic test times out waiting for an output
file, `dumpNotebookDiagnostics` is supposed to reveal why the cell didn't
emit. But its only error source is an Output-channel scrape via
wdio-vscode-service, whose locator is `select[title="Tasks"]` — stale on the
pinned VS Code (^1.86.0). On the Jul-14 CI run it threw
"Can't call $$ on element with selector select[title=\"Tasks\"]" and
returned zero channels, so the kernel's actual cell error/traceback was never
captured. The only ground truth left was the .webm video, which showed the
kernel now starts (the ipykernel fix from #2006 works) but a later cell
(`%run`, or the `%sql`->`_sqldf` cell) either never runs or emits no output —
undiagnosable from CI logs alone.

*What*
- Add `dumpActiveNotebookCells()`: reads the active notebook's cells,
  execution summaries (executionOrder/success), and output items via the
  VS Code API through `browser.executeWorkbench` — no DOM selector, so a cell
  error or a never-run cell is captured directly.
- Add `dumpVscodeLogFiles()`: dumps VS Code's on-disk logs (extension host +
  Output-channel logs) resolved from `vscode.env.logUri`, another
  selector-independent source for the kernel/DBConnect error.
- Wire both into `dumpNotebookDiagnostics` ahead of the existing
  Output-channel scrape, which is kept as best-effort (its failure is already
  caught and now clearly documented as a stale locator).
- Diagnostics-only: runs solely on the failure path, changes no assertions or
  product code.

*Verification*
- `tsc --noEmit -p src/test/e2e/tsconfig.json`: 0 errors.
- eslint + prettier on the file: clean.
- (e2e itself runs only in the databricks-eng CI; this commit's purpose is to
  make the next CI run capture the cell error so the underlying
  cell-execution failure can be root-caused.)

Co-authored-by: Isaac
@rugpanov

rugpanov commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Integration tests ❌ 5 of 35 test jobs failed for 26e7b058 (30 passed).
View run

*Why*
The first diagnostics pass (dumpActiveNotebookCells) read
`window.activeNotebookEditor`, which for the `%sql` magic test printed
"<no active notebook editor>". That `.py` "Databricks notebook"
(`# Databricks notebook source` + `# MAGIC %sql`) runs in an Interactive
Window whose document is NOT the active notebook editor — the focused editor
is the plain `.py` text editor — so the active-editor-only view missed
exactly the failing cell we need to see. As a result the run captured the
notebook.ipynb failure (cell #1 `%run` never ran) but still could not show
why the `%sql`->`_sqldf` cell produced no output.

*What*
- Rename `dumpActiveNotebookCells` -> `dumpOpenNotebookCells` and iterate
  `vscode.workspace.notebookDocuments` (every open notebook doc), printing per
  document its uri + notebookType and per cell the executionOrder/success and
  output items. This captures the Interactive Window that runs the `.py`
  Databricks notebook.
- Update the call site and comments accordingly. Still diagnostics-only,
  failure-path-only; no product or assertion changes.

*Verification*
- `tsc --noEmit -p src/test/e2e/tsconfig.json`: 0 errors.
- eslint + prettier on the file: clean.
- Purpose is to make the next e2e run surface the `%sql`/`_sqldf` cell error so
  the magic-comments failure can be root-caused with evidence.

Co-authored-by: Isaac
@rugpanov

Copy link
Copy Markdown
Contributor Author

🤖 Integration tests triggered for 5b80ab31 — ⏳ running.
View run

…defined"

*Why*
The previous commit's `dumpOpenNotebookCells` defined a named nested arrow
(`const formatCell = (cell) => …`) inside the `browser.executeWorkbench`
callback. WebdriverIO v9 transpiles the spec with tsx (esbuild, keepNames on),
which rewrites a named binding as `const formatCell = __name(() => …,
"formatCell")`. `executeWorkbench` serializes the callback via `.toString()`
and evals it in the extension host, where the esbuild `__name` helper does not
exist — so the callback threw "__name is not defined" and the whole dump was
lost (CI run 29342709724 printed
"could not read open notebook documents: Error: __name is not defined").

*What*
- Inline the per-cell formatting directly into the `.map()` callbacks so there
  is no named nested binding for keepNames to wrap. Verified with the real tsx
  toolchain: `fn.toString()` of the inlined version contains no `__name`,
  whereas the named-const version emits `__name(...,"formatCell")`.
- Add a comment warning that this callback must stay inline-arrow-only.
- Behavior otherwise unchanged: still iterates `workspace.notebookDocuments`
  and prints per-cell executionOrder/success/outputs on the failure path only.

*Verification*
- Transpiled the actual file with the repo's esbuild+keepNames: 0 `__name`
  occurrences inside `dumpOpenNotebookCells`.
- `tsc --noEmit -p src/test/e2e/tsconfig.json`: 0 errors; eslint + prettier: clean.

Co-authored-by: Isaac
@rugpanov rugpanov temporarily deployed to test-trigger-is July 14, 2026 15:20 — with GitHub Actions Inactive
@rugpanov rugpanov deployed to test-trigger-is July 14, 2026 15:20 — with GitHub Actions Active
@rugpanov

Copy link
Copy Markdown
Contributor Author

🤖 Integration tests triggered for 28c6ffc8 — ⏳ running.
View run

@github-actions

Copy link
Copy Markdown
Contributor

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/vscode

Inputs:

  • PR number: 2013
  • Commit SHA: 28c6ffc8a8d0cad61b4fa262a4f7515f0497a58e

Checks will be approved automatically on success.

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.

2 participants