Skip to content

Prompt re-login on setup-local session expiry instead of a hard error - #2163

Merged
rugpanov merged 2 commits into
mainfrom
rugpanov/setup-local-relogin-prompt
Sep 1, 2026
Merged

Prompt re-login on setup-local session expiry instead of a hard error#2163
rugpanov merged 2 commits into
mainfrom
rugpanov/setup-local-relogin-prompt

Conversation

@rugpanov

@rugpanov rugpanov commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Why

When databricks environments setup-local aborts because the active profile's session can no longer be refreshed, the extension surfaced the raw CLI text as a hard error notification (which VS Code decorates with "Report this problem") and force-revealed the setup output channel. An expired session is an expected, self-service condition — the user just needs to log in again — not a defect worth reporting.

What

  • Add isReauthRequiredError, a precision-tuned matcher for the CLI's reauthenticate signal. It requires both the CLI's own databricks auth login remediation and a matching cause (reauthenticate / re-authenticate / refresh token is invalid / access token could not be retrieved), with whitespace normalized so a cause split across lines still matches.
  • Use it as a positive gate in the setup-local spawn/parse catch: on a match, show a re-login prompt — a warning (not an error) with a Login button that runs the extension's existing re-auth flow (databricks.connection.configureLogin) — and record the run as not report-worthy (not_started, reportOffered: false). No log-channel reveal and no auto-retry: the user re-runs setup once connected.
  • Anything the matcher does not recognize — a genuine spawn/parse defect, or a transient network failure — falls through to the existing report path. So a false negative (a drifted CLI wording this misses) is never worse than today's behavior, and a network error is never mislabeled as an expired session.

Testing

  • authErrors matcher: positive cases (verbatim CLI abort, hyphenated spelling, whitespace-split cause, case-insensitive) and precision negatives (generic parse error, network/host mention, index-fetch failure, cause-without-remediation, empty/non-string).
  • Controller gate: a reauth-signalled abort shows the prompt with no report action (not_started / reportOffered: false); a no-signal abort stays on the report path.
  • Deps: the prompt is a warning with a Login action that runs the re-auth command and does not reveal the log channel.
  • A gateway↔matcher integration test pins the CLI-stderr format the gate keys on, so a change to either side is caught in tests rather than in production.
  • yarn build, full unit suite (1034 passing), and yarn test:lint all pass.

Note

An earlier revision of this branch used an SDK session probe; it was replaced with this positive-gate matcher after review flagged that a blind probe misclassifies transient network failures as an expired session.

This pull request and its description were written by Isaac.

@rugpanov
rugpanov deployed to test-trigger-is August 31, 2026 14:33 — with GitHub Actions Active
@rugpanov

rugpanov commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Integration tests ❌ 1 of 41 test jobs failed for cef25ac2 (40 passed).
View run

@rugpanov
rugpanov deployed to test-trigger-is August 31, 2026 14:34 — with GitHub Actions Active
@rugpanov
rugpanov force-pushed the rugpanov/setup-local-relogin-prompt branch from cef25ac to 915168b Compare September 1, 2026 08:10
@rugpanov
rugpanov deployed to test-trigger-is September 1, 2026 08:10 — with GitHub Actions Active
@rugpanov
rugpanov deployed to test-trigger-is September 1, 2026 08:11 — with GitHub Actions Active
@rugpanov

rugpanov commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Integration tests triggered for 915168b2 — ⏳ running.
View run

@rugpanov
rugpanov force-pushed the rugpanov/setup-local-relogin-prompt branch from 915168b to 0050a09 Compare September 1, 2026 08:28
@rugpanov
rugpanov deployed to test-trigger-is September 1, 2026 08:28 — with GitHub Actions Active
@rugpanov
rugpanov deployed to test-trigger-is September 1, 2026 08:29 — with GitHub Actions Active
@rugpanov

rugpanov commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Integration tests triggered for 0050a09d — ⏳ running.
View run

*Why*
When `databricks environments setup-local` aborts because the active
profile's session can no longer be refreshed, the extension surfaced the
raw CLI text as a hard error with a "Report this problem" affordance and
force-revealed the output channel. An expired session is an expected,
self-service condition, not a defect worth reporting.

*What*
- Add `isReauthRequiredError`, a precision-tuned matcher for the CLI's
  reauthenticate signal: it requires the CLI's own `databricks auth login`
  remediation plus a matching cause (whitespace-normalized, hyphen-tolerant).
- Use it as a positive gate in the setup-local spawn/parse catch: on a match,
  show a re-login prompt (a warning with a "Login" button that runs the
  extension's existing re-auth command) and record the run as not report-worthy
  (`not_started`, `reportOffered: false`). Anything else -- a genuine defect or a
  transient network failure -- falls through to the existing report path, so a
  false negative is never worse than today's behavior and a network error is
  never mislabeled as expiry.
- No log reveal, no auto-retry -- the user re-runs setup after logging in.
- A gateway-to-matcher integration test pins the CLI-stderr format the gate
  keys on, so a change to either side fails in tests, not in production.

*Verification*
- yarn build (tsc) passes; full unit suite passes (1034 passing), incl. the
  matcher (positive/negative/precision), the controller gate (reauth vs
  report-path), the deps prompt, and the gateway integration test; yarn
  test:lint clean (the lone MOCHA_GREP warning is pre-existing in runTest.ts).

Co-authored-by: Isaac <no-reply@databricks.com>
@rugpanov
rugpanov force-pushed the rugpanov/setup-local-relogin-prompt branch from 0050a09 to c2ddf84 Compare September 1, 2026 08:34
@rugpanov
rugpanov deployed to test-trigger-is September 1, 2026 08:34 — with GitHub Actions Active
@rugpanov
rugpanov deployed to test-trigger-is September 1, 2026 08:34 — with GitHub Actions Active
@rugpanov

rugpanov commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Integration tests ✅ all 41 test jobs passed for c2ddf840.
View run

@rugpanov
rugpanov marked this pull request as ready for review September 1, 2026 09:13
@rugpanov
rugpanov deployed to test-trigger-is September 1, 2026 13:00 — with GitHub Actions Active
@rugpanov
rugpanov merged commit 3ebc920 into main Sep 1, 2026
3 of 6 checks passed
@github-actions

github-actions Bot commented Sep 1, 2026

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: 2163
  • Commit SHA: a54837f359576c30338bcc435fde957423b87c7f

Checks will be approved automatically on success.

rugpanov added a commit that referenced this pull request Sep 2, 2026
…ray showError signature (#2165)

## Why

`main` is red. Both **VSCode Extensions CI** and **Publish nightly
release** fail at the packaging typecheck (`tsc --build --force`) at tip
commit 3ebc920 (#2163) with:

```
PythonSetupEnvironmentSetup.test.ts(598,48): error TS2322:
  Type 'PythonSetupErrorAction[] | undefined' is not assignable to type 'PythonSetupErrorAction | undefined'.
PythonSetupEnvironmentSetup.test.ts(629,33): error TS2322: (same)
```

#2163 changed `showError`'s third parameter from a single
`PythonSetupErrorAction` to `PythonSetupErrorAction[]`. Every sibling
test in the file was migrated to the plural `actions` / `actions?.[0]`
form, but two tests were missed and still typed the parameter as a
single `PythonSetupErrorAction`. It's a test-only, compile-time type
mismatch — no product code is involved.

## What

In the two lagging tests, adopt the exact array shape the rest of the
file already uses:

- *"prompts re-login (no report)…"* — `shownErrors` field `action?:
PythonSetupErrorAction` → `actions?: PythonSetupErrorAction[]`; callback
param `action` → `actions`.
- *"reports a spawn/parse defect…"* — `shown` field likewise; callback
param `action` → `actions`; assertion `shown[0].action?.label` →
`shown[0].actions?.[0].label`.

No product behaviour changes.

## Verification

- `yarn build` (`tsc --build --force`) compiles clean — exit 0, no TS
errors.
- All 53 `PythonSetupEnvironmentSetup` unit tests pass in the VS Code
test host, including both previously-failing tests.

This pull request and its description were written by Isaac.

Co-authored-by: Isaac <no-reply@databricks.com>
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