Commit 25f8721
authored
Fix refresh failure caused by JSON-RPC sending [null] params to pet binary (microsoft#1442)
CI checks are failing
- `"before all" hook for "All extension commands are registered"`
- `getEnvironments finds Python installations when available`
- `refreshEnvironments completes without error`
## Root cause
`getRefreshOptions()` in `nativePythonFinder.ts` returns `undefined`
when no specific search options are needed (the common case for a full
refresh). When `undefined` is passed to
`connection.sendRequest('refresh', undefined, token)`, the
`vscode-jsonrpc` library serializes it as positional params: `[null]`.
The pet binary's Rust deserializer handles `null` and `[]` (empty array)
correctly, but **not** `[null]` (array containing null). Serde tries to
interpret the 1-element array as a `RefreshOptions` struct with 2 fields
and fails.
## Fix
Changed `getRefreshOptions()` to return `{}` instead of `undefined` when
no options are specified. This sends a proper empty JSON object over the
wire, which the pet binary correctly deserializes into `RefreshOptions {
search_kind: None, search_paths: None }` — a full global search using
configured workspace directories.
## Why `{}` is safe
- Both `search_kind` and `search_paths` are `Option<T>` in Rust — `None`
is the expected default
- Pet's own `normalize_refresh_params` already converts `null` → `{}`,
so `{}` is the canonical "no options" format
- The Rust code only accesses these fields via `if let Some(...)` guards
— no `.unwrap()` calls
- Pet has [explicit
tests](https://github.com/microsoft/python-environment-tools) confirming
empty params produce `RefreshOptions::default()`
- `{}` with both fields as `None` triggers a full global search —
identical behavior to before
## Changes
- **`src/managers/common/nativePythonFinder.ts`**: `getRefreshOptions()`
now returns `{}` instead of `undefined`, and its return type is
simplified from `RefreshOptions | undefined` to `RefreshOptions`1 parent 9a9e93a commit 25f8721
1 file changed
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
438 | | - | |
| 438 | + | |
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
456 | | - | |
| 455 | + | |
| 456 | + | |
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
| |||
0 commit comments