Skip to content

Fix refresh failure caused by JSON-RPC sending [null] params to pet binary#1442

Merged
StellaHuang95 merged 1 commit intomicrosoft:mainfrom
StellaHuang95:ciFailure
Apr 7, 2026
Merged

Fix refresh failure caused by JSON-RPC sending [null] params to pet binary#1442
StellaHuang95 merged 1 commit intomicrosoft:mainfrom
StellaHuang95:ciFailure

Conversation

@StellaHuang95
Copy link
Copy Markdown
Contributor

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 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

@StellaHuang95 StellaHuang95 merged commit 25f8721 into microsoft:main Apr 7, 2026
43 of 44 checks passed
@StellaHuang95 StellaHuang95 deleted the ciFailure branch April 7, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants